[wp-trac] [WordPress Trac] #58291: Speed up WordPress hooks addition/removal by ~20%

WordPress Trac noreply at wordpress.org
Fri May 12 22:37:47 UTC 2023


#58291: Speed up WordPress hooks addition/removal by ~20%
--------------------------+------------------------------
 Reporter:  bor0          |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Plugins       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+------------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:5 bor0]:
 > > > - No need to concatenate `'::'` - speed should be obvious here,
 fewer strings to concatenate
 > >
 > > I think this is still needed for canonical callback representation,
 see [24251] / #23265.
 >
 > I see, thanks for the additional context. However, that fix seems to
 cover only the first two cases, while the third action still produces a
 different string. We can re-introduce `::` but it still doesn't seem the
 right choice as it doesn't cover all cases.

 Let's keep `'::'` for now, it addresses the most common case as noted
 comment:5:ticket:23265, and the unit test added in [1294/tests] would
 apparently fail without it. Removing it seems like a micro-optimization
 that probably won't have a big impact compared to the other changes.

 It also matches a
 [https://www.php.net/manual/en/language.types.callable.php
 call_user_func() example], though that might not be super relevant here:
 {{{
 // Type 4: Static class method call
 call_user_func('MyClass::myCallbackMethod');
 }}}

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


More information about the wp-trac mailing list