[wp-trac] [WordPress Trac] #58457: Optimize `WP_Theme_JSON::append_to_selector`

WordPress Trac noreply at wordpress.org
Tue Jun 20 17:52:47 UTC 2023


#58457: Optimize `WP_Theme_JSON::append_to_selector`
-------------------------+--------------------------
 Reporter:  bor0         |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  6.3
Component:  General      |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  performance
-------------------------+--------------------------

Comment (by flixos90):

 In [changeset:"55950" 55950]:
 {{{
 #!CommitTicketReference repository="" revision="55950"
 Editor: Introduce `WP_Theme_JSON::prepend_to_selector()` to improve code
 quality and performance.

 The `WP_Theme_JSON::append_to_selector()` method was previously used for
 both appending and prepending which violated the single responsibility
 principle. It resulted in additional conditionals which also came at a
 performance cost, particularly because the method is called over 1,000
 times during a regular WordPress request.

 With the new `WP_Theme_JSON::prepend_to_selector()` method, there are now
 two distinct methods for the two distinct purposes. The now useless third
 parameter on `WP_Theme_JSON::append_to_selector()` has been removed
 (rather than deprecated), which is acceptable given that it is a protected
 method on a class that is not intended for extensions.

 Props bor0, costdev, flixos90, isabel_brison, oandregal, spacedmonkey.
 Fixes #58193.
 See #58457.
 }}}

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


More information about the wp-trac mailing list