]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Optimize std::basic_string_view::starts_with
authorJonathan Wakely <jwakely@redhat.com>
Thu, 30 May 2024 19:36:42 +0000 (20:36 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 28 Feb 2025 15:33:21 +0000 (15:33 +0000)
commit8443a90c4332b9c1b8c370c971777807512f7602
tree0db4542c174c2b9cc812485d20aebbd601c62669
parent3b9885ac4df2e83cec2080d5a7013b71345a7a7b
libstdc++: Optimize std::basic_string_view::starts_with

We get smaller code at all optimization levels by not creating a
temporary object, just comparing lengths first and then using
traits_type::compare. This does less work than calling substr then
operator==.

libstdc++-v3/ChangeLog:

* include/std/string_view (starts_with(basic_string_view)):
Compare lengths first and then call traits_type::compare
directly.

(cherry picked from commit 482f97e79fc29ea2d61f1425b32564a668b51e1c)
libstdc++-v3/include/std/string_view