libstdc++: Simplify basic_string_view::ends_with [PR 101361]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 13 Jul 2021 11:21:27 +0000 (12:21 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 13 Jul 2021 14:21:26 +0000 (15:21 +0100)
commit4d3eaeb4f505b0838c673ee28e7dba8687fc8272
treefb472dc6f1dd115546653ea64eb1e7663840a317
parentf75560398af6f1f696c820016f437af4e8b4265c
libstdc++: Simplify basic_string_view::ends_with [PR 101361]

The use of npos triggers a diagnostic as described in PR c++/101361.
This change replaces the use of npos with the exact length, which is
already known. We can further simplify it by inlining the effects of
compare and substr, avoiding the redundant range checks in the latter.

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

PR c++/101361
* include/std/string_view (ends_with): Use traits_type::compare
directly.
libstdc++-v3/include/std/string_view