From 0c676f363b19fb1d1196c263e363f42193081b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 11 Oct 2022 19:20:36 +0200 Subject: [PATCH] get_merged_data: start from an existing theme.json get_merged_data is now a hotpath that is called many times. By improving small things that are repeated multiple times we get more performance wins. Instead of starting with an empty WP_Theme_JSON and call the merge operation we start by using the existing WP_Theme_JSON from core. This reduces from 402 to 326 the number of calls of the low-level WP_Theme_JSON->merge method. --- src/wp-includes/class-wp-theme-json-resolver.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index 993543a55b2b7..18b997561cf05 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -548,8 +548,7 @@ public static function get_merged_data( $origin = 'custom' ) { _deprecated_argument( __FUNCTION__, '5.9.0' ); } - $result = new WP_Theme_JSON(); - $result->merge( static::get_core_data() ); + $result = static::get_core_data(); $result->merge( static::get_block_data() ); $result->merge( static::get_theme_data() );