[PATCH] D33009: [CodeView] Add an amortized O(1) random access type visitor

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 11:10:06 PDT 2017


zturner added inline comments.


================
Comment at: llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp:159
 
-CVType &RandomAccessTypeDatabase::getTypeRecord(TypeIndex Index) {
-  assert(containsTypeIndex(Index));
-  return TypeDatabase::getTypeRecord(Index);
+  int Index = ValidRecords.find_last();
+  assert(Index != -1);
----------------
rnk wrote:
> Isn't this a linear scan from the end of the bitvector? Does `Count` work instead?
This is something I've been kinda struggling with.  `Count` works as long as you assume the user is *only* append or *only* inserting randomly.  The API doesn't enforce that, and there's no good way to make it enforce that.  In practice that's how it's used though.


https://reviews.llvm.org/D33009





More information about the llvm-commits mailing list