[PATCH] D65788: [ADT] Remove O(1) requirement to range passed to llvm::size

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 05:10:27 PDT 2019


abrachet added a subscriber: dblaikie.
abrachet added a comment.

In D65788#1616378 <https://reviews.llvm.org/D65788#1616378>, @jhenderson wrote:

> How many places use this and in what context? I'm conscious of std::size which becomes available in C++17, and the natural implementation of that is to simply use the standard .size() method on a container (see https://en.cppreference.com/w/cpp/iterator/size). It also does something else for fixed-sized arrays, but this particular version doesn't work for that. Finally, why do you need llvm::size() instead of a container.size() method?


I was also curious about the use of `llvm::size()` instead of the containers size method, seems like ranges which can be computed in O(1) are almost always going to be in containers which have a size method. My particular use is with the iterators in `ObjectFile::sections(), symbols()` etc. which are not in a container with a size method and may not even be contiguous in memory.

I've added @dblaikie as a subscriber as it seems from D46976 <https://reviews.llvm.org/D46976> it was his idea to give this restriction to `llvm::size()`.


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

https://reviews.llvm.org/D65788





More information about the llvm-commits mailing list