summaryrefslogtreecommitdiffstats
path: root/base/values.cc
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 15:23:30 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 15:23:30 +0000
commit6e680cfca66d0461f2824ccb5128e4f9cbb20bb6 (patch)
tree8810c22ec7ab357f5cc15cc508565d2a9872dcf5 /base/values.cc
parent97570b99a4341b1d1d6512f5d82b43c3123eb927 (diff)
downloadchromium_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.cc')
-rw-r--r--base/values.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/base/values.cc b/base/values.cc
index 8d7ca35..d561d68 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -694,6 +694,10 @@ void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) {
}
}
+void DictionaryValue::Swap(DictionaryValue* other) {
+ dictionary_.swap(other->dictionary_);
+}
+
DictionaryValue* DictionaryValue::DeepCopy() const {
DictionaryValue* result = new DictionaryValue;
@@ -908,6 +912,10 @@ ListValue::const_iterator ListValue::Find(const Value& value) const {
return std::find_if(list_.begin(), list_.end(), ValueEquals(&value));
}
+void ListValue::Swap(ListValue* other) {
+ list_.swap(other->list_);
+}
+
bool ListValue::GetAsList(ListValue** out_value) {
if (out_value)
*out_value = this;