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

Unified Diff: sky/engine/tonic/dart_class_library.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_class_library.h ('k') | sky/engine/tonic/dart_gc_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/tonic/dart_class_library.cc
diff --git a/sky/engine/tonic/dart_class_library.cc b/sky/engine/tonic/dart_class_library.cc
index 7fb3424796737ae0649e14ab2c296e3358a2c502..986eb3930e487ced1de70624b6996073366f8d0c 100644
--- a/sky/engine/tonic/dart_class_library.cc
+++ b/sky/engine/tonic/dart_class_library.cc
@@ -21,13 +21,14 @@ DartClassLibrary::~DartClassLibrary() {
Dart_PersistentHandle DartClassLibrary::GetClass(const DartWrapperInfo& info) {
DCHECK(provider_);
- const auto& result = cache_.add(&info, nullptr);
- if (!result.isNewEntry)
- return result.storedValue->value;
-
+ const auto& result = cache_.insert(std::make_pair(&info, nullptr));
+ if (!result.second) {
+ // Already present, return value.
+ return result.first->second;
+ }
Dart_Handle class_handle = provider_->GetClassByName(info.interface_name);
- result.storedValue->value = Dart_NewPersistentHandle(class_handle);
- return result.storedValue->value;
+ result.first->second = Dart_NewPersistentHandle(class_handle);
+ return result.first->second;
}
} // namespace blink
« no previous file with comments | « sky/engine/tonic/dart_class_library.h ('k') | sky/engine/tonic/dart_gc_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698