[wp-trac] [WordPress Trac] #58012: Replace usage of strpos with str_starts_with

WordPress Trac noreply at wordpress.org
Wed Mar 29 15:44:50 UTC 2023


#58012: Replace usage of strpos with str_starts_with
----------------------------------------+------------------------------
 Reporter:  spacedmonkey                |       Owner:  (none)
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  General                     |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  needs-patch good-first-bug  |     Focuses:
----------------------------------------+------------------------------

Comment (by jorbin):

 I ran a quick test - https://3v4l.org/dUbZ9 which shows that strpos is
 slightly faster before PHP8 and across 1,000,000 runs, the time saved is
 only about 3.5e-8 seconds. As we have less than 1000 instances in code
 that would change, this doesn't seem like it will move the performance
 needle substantially.

 To me, this feels like a micro-optimization that is best done as a part of
 other code changes and not done on its own. After all,
 [https://make.wordpress.org/core/handbook/contribute/code-refactoring/
 Code refactoring should not be done just because we can.]

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


More information about the wp-trac mailing list