Improve SmallPtrSetImpl::count implementation
authorserge-sans-paille <sguelton@redhat.com>
Mon, 1 Jun 2020 05:49:19 +0000 (07:49 +0200)
committerserge-sans-paille <sguelton@redhat.com>
Mon, 1 Jun 2020 05:49:19 +0000 (07:49 +0200)
commit11efb0837c897c709ae162eb5ebabb460fc537ff
treea2999a43481eadc4d1658aeb36df16d6850dffff
parentaf38074874c605f9e598ae3f7e5d4befa3fe92bb
Improve SmallPtrSetImpl::count implementation

Relying on the find method implies a roundtrip to the iterator world, which is
not costless because iterator creation involves a few check to ensure the
iterator is in a valid position (through the SmallPtrSetIteratorImpl::AdvanceIfNotValid
method). It turns out that the result of SmallPtrSetImpl::find_imp is either
valid or the EndPointer, so there's no need to go through that abstraction,
and the compiler cannot guess it.

Differential Revision: https://reviews.llvm.org/D80708
llvm/include/llvm/ADT/SmallPtrSet.h