Bug 1341367 - Make the sense of HashTable::Ptr::isValid match its name r=luke
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 06 Jun 2017 11:25:57 +0100
changeset 413030 711a50eff7d819795570f82d2e9a696659a592d5
parent 413029 cab8d95ff4a9ae4cc21d42592fc6cac781d142b3
child 413031 8adc00c59534ca1ad6c30908d1e166c679bcf4fc
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1341367
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1341367 - Make the sense of HashTable::Ptr::isValid match its name r=luke
js/public/HashTable.h
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -910,21 +910,21 @@ class HashTable : private AllocPolicy
           : entry_(nullptr)
 #ifdef JS_DEBUG
           , table_(nullptr)
           , generation(0)
 #endif
         {}
 
         bool isValid() const {
-            return !entry_;
+            return !!entry_;
         }
 
         bool found() const {
-            if (isValid())
+            if (!isValid())
                 return false;
 #ifdef JS_DEBUG
             MOZ_ASSERT(generation == table_->generation());
 #endif
             return entry_->isLive();
         }
 
         explicit operator bool() const {
@@ -1784,22 +1784,22 @@ class HashTable : private AllocPolicy
         return p;
     }
 
     template <typename... Args>
     MOZ_MUST_USE bool add(AddPtr& p, Args&&... args)
     {
         mozilla::ReentrancyGuard g(*this);
         MOZ_ASSERT(table);
-        MOZ_ASSERT_IF(!p.isValid(), p.table_ == this);
+        MOZ_ASSERT_IF(p.isValid(), p.table_ == this);
         MOZ_ASSERT(!p.found());
         MOZ_ASSERT(!(p.keyHash & sCollisionBit));
 
         // Check for error from ensureHash() here.
-        if (p.isValid())
+        if (!p.isValid())
             return false;
 
         // Changing an entry from removed to live does not affect whether we
         // are overloaded and can be handled separately.
         if (p.entry_->isRemoved()) {
             if (!this->checkSimulatedOOM())
                 return false;
             METER(stats.addOverRemoved++);
@@ -1855,17 +1855,17 @@ class HashTable : private AllocPolicy
     }
 
     // Note: |l| may be a reference to a piece of |u|, so this function
     // must take care not to use |l| after moving |u|.
     template <typename... Args>
     MOZ_MUST_USE bool relookupOrAdd(AddPtr& p, const Lookup& l, Args&&... args)
     {
         // Check for error from ensureHash() here.
-        if (p.isValid())
+        if (!p.isValid())
             return false;
 
 #ifdef JS_DEBUG
         p.generation = generation();
         p.mutationCount = mutationCount;
 #endif
         {
             mozilla::ReentrancyGuard g(*this);