[wp-trac] [WordPress Trac] #58220: Replace usage of substr with str_starts_with and str_ends_with

WordPress Trac noreply at wordpress.org
Tue Jun 27 00:17:05 UTC 2023


#58220: Replace usage of substr with str_starts_with and str_ends_with
------------------------------+-----------------------------
 Reporter:  Soean             |       Owner:  SergeyBiryukov
     Type:  enhancement       |      Status:  closed
 Priority:  normal            |   Milestone:  6.3
Component:  General           |     Version:
 Severity:  normal            |  Resolution:  fixed
 Keywords:  has-patch commit  |     Focuses:  performance
------------------------------+-----------------------------

Comment (by azaozz):

 Replying to [comment:17 spacedmonkey]:
 > Performance testing:
 >
 > Run on PHP 7.4 - 2020 theme and theme test data imported, trunk vs PR.
 Runned 500 times
 > ...
 > This change is a net benefit. @azaozz

 Mmmmm, these results are really really interesting :)

 So running the PHP native `strpos()` is slower than calling a (polifill)
 function with the exact same `strpos()` and with a conditional before it?
 Will keep it in mind but sounds unbelievable! :)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58220#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list