[llvm] 7451bf0 - [SLP] use std::distance/find to reduce code; NFC
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 01:34:17 PDT 2020
> On Sep 23, 2020, at 22:39, David Blaikie via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> Looks like this is a SmallVector, so it has random access iterators if
> I'm reading the right code - could you use subtraction instead of
> std::distance? (std::distance tends to be more relevant in generic
> code where an iterator might not support random access, so it can fall
> back to iteration to compute the difference)
Or perhaps use llvm::size from STLExtras.h? https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/ADT/STLExtras.h#L1473
This should only be available for iterators that guarantee the distance can be computed in O(1), although it then still delegates to std::distance.
More information about the llvm-commits
mailing list