[Bug libstdc++/59048] operator== between std::string and const char* slower than strcmp

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jun 14 20:19:32 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59048

--- Comment #19 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:1b65779f46f16b4fffd0591f5e58722c1e7cde8d

commit r13-1095-g1b65779f46f16b4fffd0591f5e58722c1e7cde8d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jun 14 14:54:27 2022 +0100

    libstdc++: Inline all basic_string::compare overloads [PR59048]

    Defining the compare member functions inline allows calls to
    traits_type::length and std::min to be inlined, taking advantage of
    constant expression arguments. When not inline, the compiler prefers to
    use the explicit instantiation definitions in libstdc++.so and can't
    take advantage of constant arguments.

    libstdc++-v3/ChangeLog:

            PR libstdc++/59048
            * include/bits/basic_string.h (compare): Define inline.
            * include/bits/basic_string.tcc (compare): Remove out-of-line
            definitions.
            * include/bits/cow_string.h (compare): Define inline.
            * testsuite/21_strings/basic_string/operations/compare/char/3.cc:
            New test.


More information about the Gcc-bugs mailing list