mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Editor: Optimize is_callable()
checks in traverse_and_serialize_blocks()
.
This aims to improve performance by reducing the number of function calls. Follow-up to [56644]. Props welcher, Cybr, mukesh27, aristath. Fixes #62063. Built from https://develop.svn.wordpress.org/trunk@59077 git-svn-id: http://core.svn.wordpress.org/trunk@58473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5b3b3f7df2
commit
d2c835af27
@ -1690,8 +1690,11 @@ function traverse_and_serialize_blocks( $blocks, $pre_callback = null, $post_cal
|
|||||||
$result = '';
|
$result = '';
|
||||||
$parent_block = null; // At the top level, there is no parent block to pass to the callbacks; yet the callbacks expect a reference.
|
$parent_block = null; // At the top level, there is no parent block to pass to the callbacks; yet the callbacks expect a reference.
|
||||||
|
|
||||||
|
$pre_callback_is_callable = is_callable( $pre_callback );
|
||||||
|
$post_callback_is_callable = is_callable( $post_callback );
|
||||||
|
|
||||||
foreach ( $blocks as $index => $block ) {
|
foreach ( $blocks as $index => $block ) {
|
||||||
if ( is_callable( $pre_callback ) ) {
|
if ( $pre_callback_is_callable ) {
|
||||||
$prev = 0 === $index
|
$prev = 0 === $index
|
||||||
? null
|
? null
|
||||||
: $blocks[ $index - 1 ];
|
: $blocks[ $index - 1 ];
|
||||||
@ -1702,7 +1705,7 @@ function traverse_and_serialize_blocks( $blocks, $pre_callback = null, $post_cal
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_callable( $post_callback ) ) {
|
if ( $post_callback_is_callable ) {
|
||||||
$next = count( $blocks ) - 1 === $index
|
$next = count( $blocks ) - 1 === $index
|
||||||
? null
|
? null
|
||||||
: $blocks[ $index + 1 ];
|
: $blocks[ $index + 1 ];
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.7-alpha-59076';
|
$wp_version = '6.7-alpha-59077';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user