libstdc++: Extend memcmp optimization in std::lexicographical_compare
authorFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 10 Jun 2020 16:48:46 +0000 (17:48 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 10 Jun 2020 16:48:56 +0000 (17:48 +0100)
commit3a391adf7a38780f8d01dbac08a2a143fc80b469
tree23d1707474fbf0426ded120821c4cb65276c0824
parent371cc683371bedb0e53ebcee0c0e89604a1e74b1
libstdc++: Extend memcmp optimization in std::lexicographical_compare

Make the memcmp optimization work for std::deque iterators and safe
iterators.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

2020-06-08  François Dumont  <fdumont@gcc.gnu.org>
    Jonathan Wakely  <jwakely@redhat.com>

* include/bits/deque.tcc (__lex_cmp_dit): New.
(__lexicographical_compare_aux1): Define overloads for deque
iterators.
* include/bits/stl_algobase.h (__lexicographical_compare::__3way):
New static member function.
(__lexicographical_compare<true>::__3way): Likewise.
(__lexicographical_compare<true>::__lc): Use __3way.
(__lexicographical_compare_aux): Rename to
__lexicographical_compare_aux1 and declare overloads for deque
iterators.
(__lexicographical_compare_aux): Define new forwarding function
that calls __lexicographical_compare_aux1 and declare new overloads
for safe iterators.
(lexicographical_compare): Do not use __niter_base on
parameters.
* include/debug/safe_iterator.tcc
(__lexicographical_compare_aux): Define overloads for safe
iterators.
* testsuite/25_algorithms/lexicographical_compare/1.cc: Add
checks with random access iterators.
* testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc:
New test.
libstdc++-v3/include/bits/deque.tcc
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/include/debug/safe_iterator.tcc
libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc
libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc [new file with mode: 0644]