[wp-trac] [WordPress Trac] #58012: Replace usage of strpos with str_starts_with
    WordPress Trac 
    noreply at wordpress.org
       
    Tue May  2 19:43:03 UTC 2023
    
    
  
#58012: Replace usage of strpos with str_starts_with
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:
                                                 |  SergeyBiryukov
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.3
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  good-first-bug has-patch 2nd-        |     Focuses:
  opinion                                        |  performance
-------------------------------------------------+-------------------------
Changes (by azaozz):
 * keywords:  good-first-bug has-patch commit => good-first-bug has-patch
     2nd-opinion
 * status:  closed => reopened
 * focuses:   => performance
 * resolution:  fixed =>
Comment:
 Same considerations as #58206. This seems premature.
 Currently [https://wordpress.org/about/stats/ only ~20% of the WP
 installs] are on PHP 8+. The question is: how much slower is using the
 polyfill on PHP 7.4?
 A quick test shows it at about 50% slower:
 {{{
 2.439975ms
 0 === strpos(), 100000 times
 3.588421ms
 str_starts_with(), 100000 times
 }}}
 It's not as bad as the `str_contains()` polyfill but will still slow down
 80% of the WP sites a little. Perhaps better to "refactor" this when at
 least 50% of WP is on PHP 8+.
-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58012#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
    
    
More information about the wp-trac
mailing list