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

Unified Diff: src/base/hashmap.h

Issue 2687933003: [Parser] Cache and clone initial AstValueFactory string_table_. (Closed)
Patch Set: Address comments Created 3 years, 10 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 | « src/ast/ast-value-factory.cc ('k') | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/hashmap.h
diff --git a/src/base/hashmap.h b/src/base/hashmap.h
index e643b2f2acb17bd8c2821f4f84513101222ef9c8..4436a2d949b36cc575b6d349310e64a5856906ea 100644
--- a/src/base/hashmap.h
+++ b/src/base/hashmap.h
@@ -40,6 +40,11 @@ class TemplateHashMapImpl {
MatchFun match = MatchFun(),
AllocationPolicy allocator = AllocationPolicy());
+ // Clones the given hashmap and creates a copy with the same entries.
+ TemplateHashMapImpl(const TemplateHashMapImpl<Key, Value, MatchFun,
+ AllocationPolicy>* original,
+ AllocationPolicy allocator = AllocationPolicy());
+
~TemplateHashMapImpl();
// If an entry with matching key is found, returns that entry.
@@ -119,6 +124,8 @@ class TemplateHashMapImpl {
uint32_t hash,
AllocationPolicy allocator = AllocationPolicy());
void Resize(AllocationPolicy allocator);
+
+ DISALLOW_COPY_AND_ASSIGN(TemplateHashMapImpl);
};
template <typename Key, typename Value, typename MatchFun,
class AllocationPolicy>
@@ -131,6 +138,19 @@ TemplateHashMapImpl<Key, Value, MatchFun, AllocationPolicy>::
template <typename Key, typename Value, typename MatchFun,
class AllocationPolicy>
+TemplateHashMapImpl<Key, Value, MatchFun, AllocationPolicy>::
+ TemplateHashMapImpl(const TemplateHashMapImpl<Key, Value, MatchFun,
+ AllocationPolicy>* original,
+ AllocationPolicy allocator)
+ : capacity_(original->capacity_),
+ occupancy_(original->occupancy_),
+ match_(original->match_) {
+ map_ = reinterpret_cast<Entry*>(allocator.New(capacity_ * sizeof(Entry)));
+ memcpy(map_, original->map_, capacity_ * sizeof(Entry));
+}
+
+template <typename Key, typename Value, typename MatchFun,
+ class AllocationPolicy>
TemplateHashMapImpl<Key, Value, MatchFun,
AllocationPolicy>::~TemplateHashMapImpl() {
AllocationPolicy::Delete(map_);
@@ -382,6 +402,14 @@ class CustomMatcherTemplateHashMapImpl
AllocationPolicy allocator = AllocationPolicy())
: Base(capacity, HashEqualityThenKeyMatcher<void*, MatchFun>(match),
allocator) {}
+
+ CustomMatcherTemplateHashMapImpl(
+ const CustomMatcherTemplateHashMapImpl<AllocationPolicy>* original,
+ AllocationPolicy allocator = AllocationPolicy())
+ : Base(original, allocator) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CustomMatcherTemplateHashMapImpl);
};
typedef CustomMatcherTemplateHashMapImpl<DefaultAllocationPolicy>
« no previous file with comments | « src/ast/ast-value-factory.cc ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698