[PATCH] D77621: ADT: SmallVector size & capacity use word-size integers when elements are small.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 12:54:45 PDT 2020


dblaikie added a comment.

Please update the patch description/subject line.

@dexonsmith I'll leave this to you for final approval, since it was your idea/you've been touching things here. But looks like about the right direction.



================
Comment at: llvm/include/llvm/ADT/SmallVector.h:47
 protected:
+  typedef Size_T size_type;
+
----------------
Don't think this typedef is really pulling its weight - probably just refer to the template type parameter directly?


================
Comment at: llvm/include/llvm/ADT/SmallVector.h:53
+  // The maximum size depends on size_type used.
+  size_t SizeMax() { return size_type(-1ULL); }
 
----------------
I'd probably use numeric_limits here & make this static constexpr


================
Comment at: llvm/include/llvm/ADT/SmallVector.h:132
+    : public SmallVectorBase<SmallVectorSizeType<T>> {
   /// Find the address of the first element.  For this pointer math to be valid
   /// with small-size of 0 for T with lots of alignment, it's important that
----------------
I'd probably add a "using Base = SmallVectorBase<SmallVectorSizeType<T>>" here, and then use that in the ctor and grow_pod.

Also down by the other using decls maybe add "using Base::size/Base::capacity/Base::empty" so you don't have to "this->" everything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77621





More information about the llvm-commits mailing list