[PATCH] D121934: [llvm][StringMap]Extract createTable and getHashTable functions.

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 17 20:14:57 PDT 2022


skan added inline comments.


================
Comment at: llvm/lib/Support/StringMap.cpp:21
 /// accommodate \p NumEntries without need to grow().
-static unsigned getMinBucketToReserveForEntries(unsigned NumEntries) {
+static inline unsigned getMinBucketToReserveForEntries(unsigned NumEntries) {
   // Ensure that "NumEntries * 4 < NumBuckets * 3"
----------------
This change is not reflected in the commit message...


================
Comment at: llvm/lib/Support/StringMap.cpp:57-65
-  TheTable = static_cast<StringMapEntryBase **>(safe_calloc(
-      NewNumBuckets + 1, sizeof(StringMapEntryBase **) + sizeof(unsigned)));
+  TheTable = createTable(NewNumBuckets);
 
   // Set the member only if TheTable was successfully allocated
   NumBuckets = NewNumBuckets;
-
-  // Allocate one extra bucket, set it to look filled so the iterators stop at
----------------
I am not an expert here, Is it always safe to change the order of the three statements?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121934



More information about the llvm-commits mailing list