Make WordPress Core

Changeset 59077


Ignore:
Timestamp:
09/21/2024 02:39:52 PM (4 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r59009 r59077  
    16911691    $parent_block = null; // At the top level, there is no parent block to pass to the callbacks; yet the callbacks expect a reference.
    16921692
     1693    $pre_callback_is_callable  = is_callable( $pre_callback );
     1694    $post_callback_is_callable = is_callable( $post_callback );
     1695
    16931696    foreach ( $blocks as $index => $block ) {
    1694         if ( is_callable( $pre_callback ) ) {
     1697        if ( $pre_callback_is_callable ) {
    16951698            $prev = 0 === $index
    16961699                ? null
     
    17031706        }
    17041707
    1705         if ( is_callable( $post_callback ) ) {
     1708        if ( $post_callback_is_callable ) {
    17061709            $next = count( $blocks ) - 1 === $index
    17071710                ? null
Note: See TracChangeset for help on using the changeset viewer.