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

Unified Diff: sky/engine/tonic/dart_gc_context.cc

Issue 1228353005: Remove some HashMap (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/tonic/dart_gc_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/tonic/dart_gc_context.cc
diff --git a/sky/engine/tonic/dart_gc_context.cc b/sky/engine/tonic/dart_gc_context.cc
index 9329a56d4156dc1b12ea974df177ec7153cef24a..5d3b79103a0151c0a236d508bb9ebaa26aad5aca 100644
--- a/sky/engine/tonic/dart_gc_context.cc
+++ b/sky/engine/tonic/dart_gc_context.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <utility>
+
#include "sky/engine/tonic/dart_gc_context.h"
namespace blink {
@@ -15,13 +17,14 @@ DartGCContext::~DartGCContext() {
Dart_WeakReferenceSet DartGCContext::AddToSetForRoot(
const void* root,
Dart_WeakPersistentHandle handle) {
- const auto& it = references_.add(root, nullptr);
- if (!it.isNewEntry) {
- Dart_AppendToWeakReferenceSet(it.storedValue->value, handle, handle);
- return it.storedValue->value;
+ const auto& result = references_.insert(std::make_pair(root, nullptr));
+ if (!result.second) {
+ // Already present.
+ Dart_AppendToWeakReferenceSet(result.first->second, handle, handle);
+ return result.first->second;
}
- it.storedValue->value = Dart_NewWeakReferenceSet(builder_, handle, handle);
- return it.storedValue->value;
+ result.first->second = Dart_NewWeakReferenceSet(builder_, handle, handle);
+ return result.first->second;
}
} // namespace blink
« no previous file with comments | « sky/engine/tonic/dart_gc_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698