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

Side by Side Diff: base/values.cc

Issue 2811053002: Reland 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
170 Value& Value::operator=(const Value& that) { 174 Value& Value::operator=(const Value& that) {
171 if (type_ == that.type_) { 175 if (type_ == that.type_) {
172 InternalCopyAssignFromSameType(that); 176 InternalCopyAssignFromSameType(that);
173 } else { 177 } else {
174 // This is not a self assignment because the type_ doesn't match. 178 // This is not a self assignment because the type_ doesn't match.
175 InternalCleanup(); 179 InternalCleanup();
176 InternalCopyConstructFrom(that); 180 InternalCopyConstructFrom(that);
177 } 181 }
178 182
179 return *this; 183 return *this;
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 } 1341 }
1338 1342
1339 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { 1343 std::ostream& operator<<(std::ostream& out, const Value::Type& type) {
1340 if (static_cast<int>(type) < 0 || 1344 if (static_cast<int>(type) < 0 ||
1341 static_cast<size_t>(type) >= arraysize(kTypeNames)) 1345 static_cast<size_t>(type) >= arraysize(kTypeNames))
1342 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; 1346 return out << "Invalid Type (index = " << static_cast<int>(type) << ")";
1343 return out << Value::GetTypeName(type); 1347 return out << Value::GetTypeName(type);
1344 } 1348 }
1345 1349
1346 } // namespace base 1350 } // 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