Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/HashTable.h |
| diff --git a/third_party/WebKit/Source/wtf/HashTable.h b/third_party/WebKit/Source/wtf/HashTable.h |
| index 1930eb03f2e42418977c19ce812b90a0ee4d59f9..c1c9349cd1e4b03629fcb9deaf070739eac3c028 100644 |
| --- a/third_party/WebKit/Source/wtf/HashTable.h |
| +++ b/third_party/WebKit/Source/wtf/HashTable.h |
| @@ -855,8 +855,23 @@ typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo |
| ++m_keyCount; |
| - if (shouldExpand()) |
| + if (shouldExpand()) { |
| entry = expand(entry); |
| + } else if (Traits::weakHandlingFlag == WeakHandlingInCollections && shouldShrink()) { |
| + // When weak hash tables are processed by the garbage collector, |
| + // elements with no other strong references to them will have their |
| + // table entries cleared. But no shrinking of the backign store is |
|
haraken
2016/06/03 05:38:10
backing
sof
2016/06/03 06:17:36
thanks, fixed
|
| + // allowed at that time, as allocations are prohibited during that |
| + // GC phase. |
| + // |
| + // With that weak processing taking care of removals, explicit |
| + // remove()s of elements is rarely done. Which implies that the |
| + // weak hash table will never be checked if it can be shrunk. |
| + // |
| + // To prevent weak hash tables with very low load factors from |
| + // developing, we perform it when adding elements instead. |
| + entry = rehash(m_tableSize / 2, entry); |
|
haraken
2016/06/03 05:38:10
Maybe can we call rehash at the end of WeakProcess
sof
2016/06/03 05:42:27
We don't allow allocations during weak processing.
|
| + } |
| return AddResult(this, entry, true); |
| } |