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

Unified Diff: src/modules.cc

Issue 1074943002: Split TemplateHashMapImpl::Lookup into two methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm (and ppc) builds Created 5 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 side-by-side diff with in-line comments
Download patch
Index: src/modules.cc
diff --git a/src/modules.cc b/src/modules.cc
index 267c398c472c74ac035c7880fa04d9773762a5dd..be45c423a53024a6a325d88496542f7c3d3f2314 100644
--- a/src/modules.cc
+++ b/src/modules.cc
@@ -15,6 +15,7 @@ namespace internal {
void ModuleDescriptor::AddLocalExport(const AstRawString* export_name,
const AstRawString* local_name,
Zone* zone, bool* ok) {
+ DCHECK(!IsFrozen());
void* key = const_cast<AstRawString*>(export_name);
ZoneAllocationPolicy allocator(zone);
@@ -25,9 +26,12 @@ void ModuleDescriptor::AddLocalExport(const AstRawString* export_name,
}
ZoneHashMap::Entry* p =
- exports_->Lookup(key, export_name->hash(), !IsFrozen(), allocator);
- if (p == nullptr || p->value != nullptr) {
+ exports_->LookupOrInsert(key, export_name->hash(), allocator);
+ DCHECK_NOT_NULL(p);
+ if (p->value != nullptr) {
+ // Duplicate export.
*ok = false;
+ return;
}
p->value = const_cast<AstRawString*>(local_name);
@@ -37,10 +41,8 @@ void ModuleDescriptor::AddLocalExport(const AstRawString* export_name,
const AstRawString* ModuleDescriptor::LookupLocalExport(
const AstRawString* export_name, Zone* zone) {
if (exports_ == nullptr) return nullptr;
- ZoneAllocationPolicy allocator(zone);
- ZoneHashMap::Entry* entry =
- exports_->Lookup(const_cast<AstRawString*>(export_name),
- export_name->hash(), false, allocator);
+ ZoneHashMap::Entry* entry = exports_->Lookup(
+ const_cast<AstRawString*>(export_name), export_name->hash());
if (entry == nullptr) return nullptr;
DCHECK_NOT_NULL(entry->value);
return static_cast<const AstRawString*>(entry->value);

Powered by Google App Engine
This is Rietveld 408576698