Index: src/hashmap.h |
diff --git a/src/hashmap.h b/src/hashmap.h |
index f94def7c3c7a04cb4c0e534074c4f94b092a0f81..41e189d67ace43fa7fd7426bec919e8af7ce34b6 100644 |
--- a/src/hashmap.h |
+++ b/src/hashmap.h |
@@ -51,6 +51,9 @@ class TemplateHashMapImpl { |
Entry* LookupOrInsert(void* key, uint32_t hash, |
AllocationPolicy allocator = AllocationPolicy()); |
+ Entry* InsertNew(void* key, uint32_t hash, |
+ AllocationPolicy allocator = AllocationPolicy()); |
+ |
// Removes the entry with matching key. |
// It returns the value of the deleted entry |
// or null if there is no value for such key. |
@@ -129,6 +132,17 @@ TemplateHashMapImpl<AllocationPolicy>::LookupOrInsert( |
return p; |
} |
+ return InsertNew(key, hash, allocator); |
+} |
+ |
+template <class AllocationPolicy> |
+typename TemplateHashMapImpl<AllocationPolicy>::Entry* |
+TemplateHashMapImpl<AllocationPolicy>::InsertNew(void* key, uint32_t hash, |
+ AllocationPolicy allocator) { |
+ // Find a matching entry. |
+ Entry* p = Probe(key, hash); |
+ DCHECK(p->key == NULL); |
+ |
// No entry found; insert one. |
p->key = key; |
p->value = NULL; |