It was reported that libstdc++'s std::find was considerably faster than
libc++'s std::find in some cases. This was tracked down to some manual
loop unrolling being done in libstdc++'s implementation.
This patch modifies std::find_if to perform such loop unrolling, and
also modifies std::find and std::find_if_not to call std::find_if
as an implementation detail so they can take advantage of any optimization
we might do in std::find_if.
As a fly-by fix, this commit significantly improves the test coverage for
the three std::find_XXXX algorithms, which was previously insufficient to
find issues in this patch.
rdar://72436671
High-level motivation question: This performance difference that you see, is it only at -O0? I would hope that the compiler does the obvious loop unrolling at -O2 at least. I'd also be interested in seeing a Godbolt link of libc++ versus libstdc++, and perhaps even some new benchmark as part of the PR.