================
@@ -192,9 +204,11 @@ class ASTVector {
       this->grow(C, this->size()+NumInputs);
 
     // Copy the new elements over.
-    // TODO: NEED To compile time dispatch on whether in_iter is a random 
access
-    // iterator to use the fast uninitialized_copy.
----------------
snarang181 wrote:

@zwuis,thanks for your review.

std::distance and std::uninitialized_copy both rely on iterator tag dispatch, 
which determines the implementation at overload resolution time rather than 
through explicit compile-time branching. While std::distance will use an O(1) 
path for random access iterators, that dispatch happens inside the library and 
isn’t guaranteed to inline cleanly into templated call sites like append(). 
Moreover, std::uninitialized_copy always performs an element-by-element loop 
regardless of iterator category, offering no benefit when the range size 
(NumInputs) is already known. Using std::uninitialized_copy_n with a 
precomputed element count avoids the per-iteration sentinel checks and enables 
the compiler to generate tighter loops.

https://github.com/llvm/llvm-project/pull/162000
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to