Editor: Improve performance of WP_Theme_JSON class by reducing usage of expensive array functions.

In many scenarios array functions are more expensive than using simpler `for` or `foreach` loops.

This changeset results in roughly 4% faster `wp_head` execution time for both block themes and classic themes. While this may seem like a small win, it is a worthwhile enhancement and only one part of several other little performance tweaks which are being worked on to improve performance of `theme.json` parsing further.

Props aristath, desrosj, jrf, spacedmonkey.
Fixes #56974.
See #57067.


git-svn-id: https://develop.svn.wordpress.org/trunk@54804 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz
2022-11-11 01:48:05 +00:00
parent e4832fb198
commit 23a646a25a
2 changed files with 92 additions and 32 deletions

View File

@@ -9,8 +9,9 @@
* @since 5.8.0
*
* @group themes
*
* @covers WP_Theme_JSON
*/
class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
/**