Title: [184949] trunk/Source/WTF
Revision
184949
Author
[email protected]
Date
2015-05-28 01:13:10 -0700 (Thu, 28 May 2015)

Log Message

Clean up HashTable constructors
https://bugs.webkit.org/show_bug.cgi?id=145369

Reviewed by Andreas Kling.

Use nullptr to initialize pointer member variables in the HashTable
default constructor. Copy and move constructors can use constructor
delegation instead of replicating all member initializations. Move
constructor should simply call HashTable::swap() instead of replicating
all the swap operations.

* wtf/HashTable.h:
(WTF::KeyTraits>::HashTable):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (184948 => 184949)


--- trunk/Source/WTF/ChangeLog	2015-05-28 07:44:41 UTC (rev 184948)
+++ trunk/Source/WTF/ChangeLog	2015-05-28 08:13:10 UTC (rev 184949)
@@ -1,3 +1,19 @@
+2015-05-28  Zan Dobersek  <[email protected]>
+
+        Clean up HashTable constructors
+        https://bugs.webkit.org/show_bug.cgi?id=145369
+
+        Reviewed by Andreas Kling.
+
+        Use nullptr to initialize pointer member variables in the HashTable
+        default constructor. Copy and move constructors can use constructor
+        delegation instead of replicating all member initializations. Move
+        constructor should simply call HashTable::swap() instead of replicating
+        all the swap operations.
+
+        * wtf/HashTable.h:
+        (WTF::KeyTraits>::HashTable):
+
 2015-05-27  Alexey Proskuryakov  <[email protected]>
 
         [Mac] Fix clang static analyzer build

Modified: trunk/Source/WTF/wtf/HashTable.h (184948 => 184949)


--- trunk/Source/WTF/wtf/HashTable.h	2015-05-28 07:44:41 UTC (rev 184948)
+++ trunk/Source/WTF/wtf/HashTable.h	2015-05-28 08:13:10 UTC (rev 184949)
@@ -532,13 +532,13 @@
 
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     inline HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::HashTable()
-        : m_table(0)
+        : m_table(nullptr)
         , m_tableSize(0)
         , m_tableSizeMask(0)
         , m_keyCount(0)
         , m_deletedCount(0)
 #if CHECK_HASHTABLE_ITERATORS
-        , m_iterators(0)
+        , m_iterators(nullptr)
         , m_mutex(std::make_unique<std::mutex>())
 #endif
 #if DUMP_HASHTABLE_STATS_PER_TABLE
@@ -1155,18 +1155,7 @@
 
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::HashTable(const HashTable& other)
-        : m_table(0)
-        , m_tableSize(0)
-        , m_tableSizeMask(0)
-        , m_keyCount(0)
-        , m_deletedCount(0)
-#if CHECK_HASHTABLE_ITERATORS
-        , m_iterators(0)
-        , m_mutex(std::make_unique<std::mutex>())
-#endif
-#if DUMP_HASHTABLE_STATS_PER_TABLE
-        , m_stats(std::make_unique<Stats>(*other.m_stats))
-#endif
+        : HashTable()
     {
         // Copy the hash table the dumb way, by adding each element to the new table.
         // It might be more efficient to copy the table slots, but it's not clear that efficiency is needed.
@@ -1206,29 +1195,9 @@
 
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     inline HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::HashTable(HashTable&& other)
-#if CHECK_HASHTABLE_ITERATORS
-        : m_iterators(nullptr)
-        , m_mutex(std::make_unique<std::mutex>())
-#endif
+        : HashTable()
     {
-        other.invalidateIterators();
-
-        m_table = other.m_table;
-        m_tableSize = other.m_tableSize;
-        m_tableSizeMask = other.m_tableSizeMask;
-        m_keyCount = other.m_keyCount;
-        m_deletedCount = other.m_deletedCount;
-
-        other.m_table = nullptr;
-        other.m_tableSize = 0;
-        other.m_tableSizeMask = 0;
-        other.m_keyCount = 0;
-        other.m_deletedCount = 0;
-
-#if DUMP_HASHTABLE_STATS_PER_TABLE
-        m_stats = WTF::move(other.m_stats);
-        other.m_stats = nullptr;
-#endif
+        swap(other);
     }
 
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to