Skip to content
Snippets Groups Projects
  • Jonathan Wakely's avatar
    482f97e7
    libstdc++: Optimize std::basic_string_view::starts_with · 482f97e7
    Jonathan Wakely authored
    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.
    482f97e7
    History
    libstdc++: Optimize std::basic_string_view::starts_with
    Jonathan Wakely authored
    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.