Index: runtime/vm/hash_map.h |
diff --git a/runtime/vm/hash_map.h b/runtime/vm/hash_map.h |
index fefd788bfeacc6203e7ec0b3d83665f033b2d8d1..babaecae089005d40874837745e2cb7c34f5558b 100644 |
--- a/runtime/vm/hash_map.h |
+++ b/runtime/vm/hash_map.h |
@@ -28,7 +28,20 @@ class DirectChainedHashMap: public ValueObject { |
bool IsEmpty() const { return count_ == 0; } |
- private: |
+ void Clear() { |
+ if (!IsEmpty()) { |
+ count_ = 0; |
+ memset(array_, 0, sizeof(HashMapListElement) * array_size_); |
+ memset(lists_, 0, sizeof(HashMapListElement) * lists_size_); |
+ lists_[0].next = kNil; |
+ for (intptr_t i = 1; i < lists_size_; ++i) { |
+ lists_[i].next = i - 1; |
+ } |
+ free_list_head_ = lists_size_ - 1; |
+ } |
+ } |
+ |
+ protected: |
// A linked list of T values. Stored in arrays. |
struct HashMapListElement { |
typename KeyValueTrait::Pair kv; |