Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Optimize string_view::operator== when comparing 2 empty string_views #3310

@Thomas1664

Description

@Thomas1664

I discovered room for optimization when comparing 2 empty std::string_view s in GCC. However, Clang already seems to be optimized for this use case. See this quick bench run: https://quick-bench.com/q/FZc2abFbpI5Q_lEHXF7sNGC_Jn4 . Looking at this implementation of the STL, it seems like there is room for improvement as well: if both std:string_view s have the same size, something like memcmp is called. I couldn't verify this because quick bench doesn't support MSVC (yet).

I originally discovered this optimization here: microsoft/vcpkg-tool#843

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedSomething works now, yay!performanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions