From 8bd5d74be2844f3b6cd883519ecc775cf77d1a4d Mon Sep 17 00:00:00 2001 From: davidbaumwald Date: Thu, 24 Aug 2023 19:59:17 +0000 Subject: [PATCH] Editor: Optimize `wp_get_block_css_selector` to remove `array_merge` calls for better performance. Some block themes like TT3 use `wp_get_block_css_selector` to determine a CSS selector based on block type and other parameters. However, recent performance profiling indicated a bottleneck in `wp_get_block_css_selector`, particularly sections that utilize `array_merge`. By slightly refactoring these sections, `array_merge` calls can be avoided which increases performance. Props mukesh27, joemcgill, daxelrod, tabrisrp. Fixes #59178. Built from https://develop.svn.wordpress.org/trunk@56457 git-svn-id: http://core.svn.wordpress.org/trunk@55969 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/global-styles-and-settings.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/global-styles-and-settings.php b/wp-includes/global-styles-and-settings.php index 6ff5673318..1258f1f4e3 100644 --- a/wp-includes/global-styles-and-settings.php +++ b/wp-includes/global-styles-and-settings.php @@ -539,7 +539,7 @@ function wp_get_block_css_selector( $block_type, $target = 'root', $fallback = f // Prefer the selectors API if available. if ( $has_selectors ) { // Look for selector under `feature.root`. - $path = array_merge( $target, array( 'root' ) ); + $path = array( current( $target ), 'root' ); $feature_selector = _wp_array_get( $block_type->selectors, $path, null ); if ( $feature_selector ) { @@ -553,7 +553,7 @@ function wp_get_block_css_selector( $block_type, $target = 'root', $fallback = f } // Try getting old experimental supports selector value. - $path = array_merge( $target, array( '__experimentalSelector' ) ); + $path = array( current( $target ), '__experimentalSelector' ); $feature_selector = _wp_array_get( $block_type->supports, $path, null ); // Nothing to work with, provide fallback or null. diff --git a/wp-includes/version.php b/wp-includes/version.php index c04223e818..ee657bc123 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56456'; +$wp_version = '6.4-alpha-56457'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.