[PATCH] D16672: SmallPtrSet: Avoid initializing Array in the small case.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 27 22:22:08 PST 2016


chandlerc added inline comments.

================
Comment at: include/llvm/ADT/SmallPtrSet.h:206-208
@@ -200,3 +205,5 @@
   void AdvanceIfNotValid() {
-    assert(Bucket <= End);
-    while (Bucket != End &&
+    const void *const *End = Set->CurArray +
+      (Set->isSmall() ? Set->NumElements : Set->CurArraySize);
+    assert(Bucket <= Set->CurArray + Set->CurArraySize);
+
----------------
If we're going to iterate specially in the small case, why not completely specialize the iteration? Notably, can't you skip the tombstone test in the loop when small?

================
Comment at: include/llvm/ADT/SmallPtrSet.h:214-215
@@ -205,2 +213,4 @@
       ++Bucket;
+    if (Bucket >= End)
+      Bucket = Set->CurArray + Set->CurArraySize;
   }
----------------
Why not adjust the end iterator in the small case?


Repository:
  rL LLVM

http://reviews.llvm.org/D16672





More information about the llvm-commits mailing list