[PATCH] D121726: [llvm][ADT]Remove duplicate code in llvm::StringMapImpl::RehashTable

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 13:12:52 PDT 2022


dexonsmith accepted this revision.
dexonsmith added a comment.

LGTM too, assuming you fix the comment, which I think is now backwards (doesn't have to be the wording I suggested inline).



================
Comment at: llvm/lib/Support/StringMap.cpp:229-232
+      // Fast case, bucket available, otherwise probe for a spot.
       unsigned FullHash = HashTable[I];
       unsigned NewBucket = FullHash & (NewSize - 1);
+      if (NewTableArray[NewBucket]) {
----------------
I think the comment is backwards now!

I suggest:
```
      // If the bucket is not available, probe for a spot.
```



================
Comment at: llvm/lib/Support/StringMap.cpp:238
       }
-
-      // Otherwise probe for a spot.
-      unsigned ProbeSize = 1;
-      do {
-        NewBucket = (NewBucket + ProbeSize++) & (NewSize - 1);
-      } while (NewTableArray[NewBucket]);
-
+      
       // Finally found a slot.  Fill it in.
----------------
Note that `clang-format` wants you to do something here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121726/new/

https://reviews.llvm.org/D121726



More information about the llvm-commits mailing list