[wp-trac] [WordPress Trac] #57756: Improve performance of get_block_templates function

WordPress Trac noreply at wordpress.org
Wed Apr 26 14:38:58 UTC 2023


#57756: Improve performance of get_block_templates function
------------------------------+--------------------------
 Reporter:  oandregal         |       Owner:  oandregal
     Type:  enhancement       |      Status:  closed
 Priority:  normal            |   Milestone:  6.3
Component:  General           |     Version:  5.8
 Severity:  normal            |  Resolution:  fixed
 Keywords:  has-patch commit  |     Focuses:  performance
------------------------------+--------------------------
Changes (by oandregal):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"55687" 55687]:
 {{{
 #!CommitTicketReference repository="" revision="55687"
 Themes: improve performance of `get_block_templates()`.

 `get_block_templates()` is responsible for finding block templates that
 match a given search. The function receives a query parameter with the
 relevant metadata (slugs of the templates, areas of the template parts,
 etc) to find the user templates (database) and theme templates (file
 directory).

 This function can be made more performant by changing how it works. Before
 this change, it processed all the block templates and discarded the ones
 that didn't match the query after it occurred. This commit makes it so it
 discards the templates that don't match the query before processing them.
 As a result, it only has to process the subset of templates that will be
 used, instead of all of them.

 This change impacts any theme with block templates. TwentyTwentyThree
 reports a 15% improvement in Time To First Byte.

 Props spacedmonkey, jorgefilipecosta, youknowriad, flixos90, mukesh27.
 Fixes #57756.
 }}}

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


More information about the wp-trac mailing list