[wp-trac] [WordPress Trac] #56745: Performance/Bug: calling array_map repeatedly inside WP_Theme_JSON::get_default_slugs is a bottleneck for page-loads.
WordPress Trac
noreply at wordpress.org
Thu Oct 6 15:26:01 UTC 2022
#56745: Performance/Bug: calling array_map repeatedly inside
WP_Theme_JSON::get_default_slugs is a bottleneck for page-loads.
--------------------------+-----------------------------
Reporter: aristath | Owner: SergeyBiryukov
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.1
Component: Themes | Version: trunk
Severity: normal | Resolution: fixed
Keywords: has-patch | Focuses: performance
--------------------------+-----------------------------
Changes (by SergeyBiryukov):
* owner: (none) => SergeyBiryukov
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"54398" 54398]:
{{{
#!CommitTicketReference repository="" revision="54398"
Themes: Replace `array_map()` usage in
`WP_Theme_JSON::get_default_slugs()`.
When loading a page on the frontend using Xdebug & Webgrind, with the
Twenty Twenty-Three theme and no plugins activated, the biggest
performance bottleneck currently (on the PHP side) is
`WP_Theme_JSON::merge()`. Analysing the data a bit more, it became evident
that `WP_Theme_JSON::get_default_slugs()` is the part of that method which
takes most of the resources and time.
Further analysis of the method revealed that `array_map()` was the call
that slowed it down.
This commit replaces the `array_map()` call with a simple `foreach` loop,
improving page load speed significantly.
Follow-up to [52275], [52364].
Props aristath.
Fixes #56745.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56745#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list