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

Side by Side Diff: base/values.cc

Issue 2811043002: Revert of Use base::flat_map for base::Value dictionary storage. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « base/values.h ('k') | base/values_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 Value::Value(StringPiece in_string) : Value(in_string.as_string()) {} 160 Value::Value(StringPiece in_string) : Value(in_string.as_string()) {}
161 161
162 Value::Value(const std::vector<char>& in_blob) : type_(Type::BINARY) { 162 Value::Value(const std::vector<char>& in_blob) : type_(Type::BINARY) {
163 binary_value_.Init(in_blob); 163 binary_value_.Init(in_blob);
164 } 164 }
165 165
166 Value::Value(std::vector<char>&& in_blob) noexcept : type_(Type::BINARY) { 166 Value::Value(std::vector<char>&& in_blob) noexcept : type_(Type::BINARY) {
167 binary_value_.Init(std::move(in_blob)); 167 binary_value_.Init(std::move(in_blob));
168 } 168 }
169 169
170 Value::Value(DictStorage&& in_dict) noexcept : type_(Type::DICTIONARY) {
171 dict_ptr_.Init(MakeUnique<DictStorage>(std::move(in_dict)));
172 }
173
174 Value& Value::operator=(const Value& that) { 170 Value& Value::operator=(const Value& that) {
175 if (type_ == that.type_) { 171 if (type_ == that.type_) {
176 InternalCopyAssignFromSameType(that); 172 InternalCopyAssignFromSameType(that);
177 } else { 173 } else {
178 // This is not a self assignment because the type_ doesn't match. 174 // This is not a self assignment because the type_ doesn't match.
179 InternalCleanup(); 175 InternalCleanup();
180 InternalCopyConstructFrom(that); 176 InternalCopyConstructFrom(that);
181 } 177 }
182 178
183 return *this; 179 return *this;
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 } 1337 }
1342 1338
1343 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { 1339 std::ostream& operator<<(std::ostream& out, const Value::Type& type) {
1344 if (static_cast<int>(type) < 0 || 1340 if (static_cast<int>(type) < 0 ||
1345 static_cast<size_t>(type) >= arraysize(kTypeNames)) 1341 static_cast<size_t>(type) >= arraysize(kTypeNames))
1346 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; 1342 return out << "Invalid Type (index = " << static_cast<int>(type) << ")";
1347 return out << Value::GetTypeName(type); 1343 return out << Value::GetTypeName(type);
1348 } 1344 }
1349 1345
1350 } // namespace base 1346 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698