mirror of
git://develop.git.wordpress.org/
synced 2025-03-15 01:19:51 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@59077 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
03b12dc311
commit
f49909e972
@ -1690,8 +1690,11 @@ function traverse_and_serialize_blocks( $blocks, $pre_callback = null, $post_cal
|
||||
$result = '';
|
||||
$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 ) {
|
||||
if ( is_callable( $pre_callback ) ) {
|
||||
if ( $pre_callback_is_callable ) {
|
||||
$prev = 0 === $index
|
||||
? null
|
||||
: $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
|
||||
? null
|
||||
: $blocks[ $index + 1 ];
|
||||
|
Loading…
x
Reference in New Issue
Block a user