[PATCH] D44810: [PDB] Make LLD PDBs look a little more like Microsoft PDBs

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 22 19:24:49 PDT 2018


zturner added inline comments.


================
Comment at: llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp:41-47
+  //   int BucketCount = 1;
+  //   int StringCount = 0;
+  //   while (true) {
+  //     ++StringCount;
+  //     if (BucketCount * 3 / 4 < StringCount)
+  //       BucketCount = BucketCount * 3 / 2 + 1;
+  //   }
----------------
majnemer wrote:
> This pseudo-code infinite loops. What's the termination condition?
The body of the loop is basically the "insert" function of the hash table, so it's trying to illustrate that on each insert, they increment the count, and if the load factor goes over 75% they multiply the number of buckets by 1.5 and rehash.

If there's a way to write the pseudocode that's more clear I'm happy to change it.

What about this:

```
// Initial conditions
int BucketCount = 1;
int StringCount = 0;

// Called each time a new string is inserted.
void onStringInserted() {
  ++StringCount;
  if (BucketCount * 3 / 4 < StringCount)
    BucketCount = BucketCount * 3 / 2 + 1;
}
```


https://reviews.llvm.org/D44810





More information about the llvm-commits mailing list