Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: base/values.cc

Issue 10035042: Rewrite base::JSONReader to be 35-40% faster, depending on the input string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix Windows, address comments Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/values.h ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/values.h" 5 #include "base/values.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/float_util.h" 9 #include "base/float_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 static_cast<const DictionaryValue*>(merge_value)); 687 static_cast<const DictionaryValue*>(merge_value));
688 continue; 688 continue;
689 } 689 }
690 } 690 }
691 // All other cases: Make a copy and hook it up. 691 // All other cases: Make a copy and hook it up.
692 SetWithoutPathExpansion(*key, merge_value->DeepCopy()); 692 SetWithoutPathExpansion(*key, merge_value->DeepCopy());
693 } 693 }
694 } 694 }
695 } 695 }
696 696
697 void DictionaryValue::Swap(DictionaryValue* other) {
698 dictionary_.swap(other->dictionary_);
699 }
700
697 DictionaryValue* DictionaryValue::DeepCopy() const { 701 DictionaryValue* DictionaryValue::DeepCopy() const {
698 DictionaryValue* result = new DictionaryValue; 702 DictionaryValue* result = new DictionaryValue;
699 703
700 for (ValueMap::const_iterator current_entry(dictionary_.begin()); 704 for (ValueMap::const_iterator current_entry(dictionary_.begin());
701 current_entry != dictionary_.end(); ++current_entry) { 705 current_entry != dictionary_.end(); ++current_entry) {
702 result->SetWithoutPathExpansion(current_entry->first, 706 result->SetWithoutPathExpansion(current_entry->first,
703 current_entry->second->DeepCopy()); 707 current_entry->second->DeepCopy());
704 } 708 }
705 709
706 return result; 710 return result;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 return false; 905 return false;
902 906
903 list_.insert(list_.begin() + index, in_value); 907 list_.insert(list_.begin() + index, in_value);
904 return true; 908 return true;
905 } 909 }
906 910
907 ListValue::const_iterator ListValue::Find(const Value& value) const { 911 ListValue::const_iterator ListValue::Find(const Value& value) const {
908 return std::find_if(list_.begin(), list_.end(), ValueEquals(&value)); 912 return std::find_if(list_.begin(), list_.end(), ValueEquals(&value));
909 } 913 }
910 914
915 void ListValue::Swap(ListValue* other) {
916 list_.swap(other->list_);
917 }
918
911 bool ListValue::GetAsList(ListValue** out_value) { 919 bool ListValue::GetAsList(ListValue** out_value) {
912 if (out_value) 920 if (out_value)
913 *out_value = this; 921 *out_value = this;
914 return true; 922 return true;
915 } 923 }
916 924
917 bool ListValue::GetAsList(const ListValue** out_value) const { 925 bool ListValue::GetAsList(const ListValue** out_value) const {
918 if (out_value) 926 if (out_value)
919 *out_value = this; 927 *out_value = this;
920 return true; 928 return true;
(...skipping 24 matching lines...) Expand all
945 if (lhs_it != end() || rhs_it != other_list->end()) 953 if (lhs_it != end() || rhs_it != other_list->end())
946 return false; 954 return false;
947 955
948 return true; 956 return true;
949 } 957 }
950 958
951 ValueSerializer::~ValueSerializer() { 959 ValueSerializer::~ValueSerializer() {
952 } 960 }
953 961
954 } // namespace base 962 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698