diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 15:23:30 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 15:23:30 +0000 |
commit | 6e680cfca66d0461f2824ccb5128e4f9cbb20bb6 (patch) | |
tree | 8810c22ec7ab357f5cc15cc508565d2a9872dcf5 /base/values.h | |
parent | 97570b99a4341b1d1d6512f5d82b43c3123eb927 (diff) | |
download | chromium_src-6e680cfca66d0461f2824ccb5128e4f9cbb20bb6.zip chromium_src-6e680cfca66d0461f2824ccb5128e4f9cbb20bb6.tar.gz chromium_src-6e680cfca66d0461f2824ccb5128e4f9cbb20bb6.tar.bz2 |
Rewrite base::JSONReader to be 35-40% faster, depending on the input string.
This change does the following:
* Parses the input string and generates the object representation in O(n) time.
* Optimizes string decoding by using StringPiece where possible, which also
introduces the JSON_DETACHABLE_CHILDREN parser option.
* Makes JSONReader a simpler interface by hiding the parser details in an
internal JSONParser class.
BUG=49212,111581,121469
TEST=Hopefully covered by all test suites. New tests added for edge cases.
Review URL: https://chromiumcodereview.appspot.com/10035042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.h')
-rw-r--r-- | base/values.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/base/values.h b/base/values.h index 4bcdc75..1d35d63 100644 --- a/base/values.h +++ b/base/values.h @@ -303,11 +303,12 @@ class BASE_EXPORT DictionaryValue : public Value { // passed out via out_value. If |out_value| is NULL, the removed value will // be deleted. This method returns true if |path| is a valid path; otherwise // it will return false and the DictionaryValue object will be unchanged. - bool Remove(const std::string& path, Value** out_value); + virtual bool Remove(const std::string& path, Value** out_value); // Like Remove(), but without special treatment of '.'. This allows e.g. URLs // to be used as paths. - bool RemoveWithoutPathExpansion(const std::string& key, Value** out_value); + virtual bool RemoveWithoutPathExpansion(const std::string& key, + Value** out_value); // Makes a copy of |this| but doesn't include empty dictionaries and lists in // the copy. This never returns NULL, even if |this| itself is empty. @@ -321,9 +322,7 @@ class BASE_EXPORT DictionaryValue : public Value { void MergeDictionary(const DictionaryValue* dictionary); // Swaps contents with the |other| dictionary. - void Swap(DictionaryValue* other) { - dictionary_.swap(other->dictionary_); - } + virtual void Swap(DictionaryValue* other); // This class provides an iterator for the keys in the dictionary. // It can't be used to modify the dictionary. @@ -425,7 +424,7 @@ class BASE_EXPORT ListValue : public Value { // passed out via |out_value|. If |out_value| is NULL, the removed value will // be deleted. This method returns true if |index| is valid; otherwise // it will return false and the ListValue object will be unchanged. - bool Remove(size_t index, Value** out_value); + virtual bool Remove(size_t index, Value** out_value); // Removes the first instance of |value| found in the list, if any, and // deletes it. |index| is the location where |value| was found. Returns false @@ -450,9 +449,7 @@ class BASE_EXPORT ListValue : public Value { const_iterator Find(const Value& value) const; // Swaps contents with the |other| list. - void Swap(ListValue* other) { - list_.swap(other->list_); - } + virtual void Swap(ListValue* other); // Iteration. iterator begin() { return list_.begin(); } |