]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Optimize std::projected<I, std::identity>
authorPatrick Palka <ppalka@redhat.com>
Thu, 22 Aug 2024 13:24:39 +0000 (09:24 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 22 Aug 2024 13:24:39 +0000 (09:24 -0400)
commit51761c50f843d5be4e24172535e4524b5072f24c
tree4694a7bf9fb7bd524eed688fdb3147d266001297
parent620232426bd83a79c81cd2be6f485834c618e920
libstdc++: Optimize std::projected<I, std::identity>

Algorithms that are generalized to take projections typically default the
projection to std::identity, which is equivalent to no projection at all.
In that case, I believe we could shortcut the projection logic to return
the iterator unchanged rather than wrapping it.  This should reduce compile
times especially after P2609R3 which made the indirect invocability
concepts more expensive to check when actual projections are involved.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (__detail::__projected): Define
an optimized partial specialization for when the projection is
std::identity.
* testsuite/24_iterators/indirect_callable/projected.cc: Verify the
optimization.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/include/bits/iterator_concepts.h
libstdc++-v3/testsuite/24_iterators/indirect_callable/projected.cc