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

Unified Diff: src/interpreter/constant-array-builder.cc

Issue 2336553002: [interpreter] Use hashmap for ConstantArrayBuilder's constant map (Closed)
Patch Set: Rebased onto master Created 4 years, 3 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
Index: src/interpreter/constant-array-builder.cc
diff --git a/src/interpreter/constant-array-builder.cc b/src/interpreter/constant-array-builder.cc
index ff3823fde2d14ce96bbc135ac00ad11cd765c5d5..e5ccb386b0f621154bbd2bb266d3130ea4c672f1 100644
--- a/src/interpreter/constant-array-builder.cc
+++ b/src/interpreter/constant-array-builder.cc
@@ -72,7 +72,7 @@ STATIC_CONST_MEMBER_DEFINITION const size_t
ConstantArrayBuilder::ConstantArrayBuilder(Zone* zone,
Handle<Object> the_hole_value)
- : constants_map_(zone),
+ : constants_map_(zone, 16),
smi_map_(zone),
smi_pairs_(zone),
the_hole_value_(the_hole_value) {
@@ -153,9 +153,8 @@ Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(Isolate* isolate) {
}
size_t ConstantArrayBuilder::Insert(Handle<Object> object) {
- auto entry = constants_map_.find(object.address());
- return (entry == constants_map_.end()) ? AllocateEntry(object)
- : entry->second;
+ return constants_map_.LookupOrInsert(object.address(),
+ [&]() { return AllocateIndex(object); });
}
ConstantArrayBuilder::index_t ConstantArrayBuilder::AllocateEntry(

Powered by Google App Engine
This is Rietveld 408576698