Index: Source/wtf/HashTable.h |
diff --git a/Source/wtf/HashTable.h b/Source/wtf/HashTable.h |
index a57d5d39d132ab86414c59e6fd0df27cc0972b87..25d7ee5008257d71f02f3793b225fe536c042aaa 100644 |
--- a/Source/wtf/HashTable.h |
+++ b/Source/wtf/HashTable.h |
@@ -61,6 +61,8 @@ namespace WTF { |
class HashTableIterator; |
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator> |
class HashTableConstIterator; |
+ template<typename Value, typename HashFunctions, typename HashTraits, typename Allocator> |
+ class LinkedHashSet; |
Mikhail
2014/04/03 07:56:44
Why is LinkedHashSet needs to be declared here?
Mads Ager (chromium)
2014/04/03 09:24:35
For the friend declaration below?
Erik Corry
2014/04/10 10:47:37
Yes.
|
template<bool x, typename T, typename U, typename V, typename W, typename X, typename Y, typename Z> |
struct WeakProcessingHashTableHelper; |
@@ -104,6 +106,7 @@ namespace WTF { |
, m_containerModifications(container->modifications()) |
#endif |
{ |
+ ASSERT(m_containerModifications == m_container->modifications()); |
} |
void checkModifications() const |
@@ -380,9 +383,15 @@ namespace WTF { |
#ifdef ASSERT_ENABLED |
int64_t modifications() const { return m_modifications; } |
void registerModification() { m_modifications++; } |
+ void checkModifications(int64_t mods) const { } |
Mikhail
2014/04/03 07:56:44
Looks like the changes in this file are unnecessar
Mads Ager (chromium)
2014/04/03 09:24:35
mods -> modifications.
Also, you should probably
Erik Corry
2014/04/10 10:47:37
No, rather the opposite, the checkModifications me
Erik Corry
2014/04/10 10:47:37
Nice catch!
|
#else |
int64_t modifications() const { return 0; } |
void registerModification() { } |
+ // HashTable and collections that build on it do not support |
+ // modifications while there is an iterator in use. The exception is |
+ // ListHashSet, which has its own iterators that tolerate modification |
+ // of the underlying set. |
+ void checkModifications(int64_t mods) const { ASSERT(mods == m_modifications); } |
#endif |
private: |
@@ -436,6 +445,7 @@ namespace WTF { |
#endif |
template<bool x, typename T, typename U, typename V, typename W, typename X, typename Y, typename Z> friend struct WeakProcessingHashTableHelper; |
+ template<typename T, typename U, typename V, typename W> friend class LinkedHashSet; |
}; |
// Set all the bits to one after the most significant bit: 00110101010 -> 00111111111. |
@@ -563,6 +573,7 @@ namespace WTF { |
inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::LookupType HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::lookupForWriting(const T& key) |
{ |
ASSERT(m_table); |
+ registerModification(); |
size_t k = 0; |
ValueType* table = m_table; |
@@ -625,6 +636,7 @@ namespace WTF { |
inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::FullLookupType HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::fullLookupForWriting(const T& key) |
{ |
ASSERT(m_table); |
+ registerModification(); |
size_t k = 0; |
ValueType* table = m_table; |
@@ -711,6 +723,7 @@ namespace WTF { |
template<typename HashTranslator, typename T, typename Extra> |
typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::add(const T& key, const Extra& extra) |
{ |
+ registerModification(); |
if (!m_table) |
expand(); |
@@ -793,6 +806,7 @@ namespace WTF { |
template<typename HashTranslator, typename T, typename Extra> |
typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::addPassingHashCode(const T& key, const Extra& extra) |
{ |
+ registerModification(); |
if (!m_table) |
expand(); |