libstdc++: Micro-optimisations for lexicographical_compare_three_way
authorJonathan Wakely <jwakely@redhat.com>
Tue, 3 Mar 2020 11:06:26 +0000 (11:06 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 3 Mar 2020 11:06:26 +0000 (11:06 +0000)
commit9b4f00dd3f799337d8b8ef5e79f5a682c8059ab9
treeb443d9547c4ac12c012084225ec211a52d9d5695
parentb07e4e7c7520ca3e798f514dec0711eea2c027be
libstdc++: Micro-optimisations for lexicographical_compare_three_way

As noted in LWG 3410 the specification in the C++20 draft performs more
iterator comparisons than necessary when the end of either range is
reached. Our implementation followed that specification. This removes
the redundant comparisons so that we do no unnecessary work as soon as
we find that we've reached the end of either range.

The odd-looking return statement is because it generates better code
than the original version that copied the global constants.

* include/bits/stl_algobase.h (lexicographical_compare_three_way):
Avoid redundant iterator comparisons (LWG 3410).
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algobase.h