diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index cfdcf28f026..4ea72c6cef2 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -361,8 +361,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr bool ends_with(basic_string_view __x) const noexcept { - return this->size() >= __x.size() - && this->compare(this->size() - __x.size(), npos, __x) == 0; + const auto __len = this->size(); + const auto __xlen = __x.size(); + return __len >= __xlen + && traits_type::compare(end() - __xlen, __x.data(), __xlen) == 0; } constexpr bool