WordPress.org

Make WordPress Core

Ticket #20776: 20776-1.diff

File 20776-1.diff, 2.3 KB (added by ericlewis, 6 years ago)

remove is_null check from apply_filters, apply_filters_ref_array, do_action, do_action_ref_array, _wp_call_all_hook. These functions can use more dev-review for possible performance gains (remove array casting suggested).

  • wp-includes/plugin.php

     
    164164                $args = func_get_args();
    165165
    166166        do {
    167                 foreach( (array) current($wp_filter[$tag]) as $the_ )
    168                         if ( !is_null($the_['function']) ){
    169                                 $args[1] = $value;
    170                                 $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
    171                         }
    172 
     167                foreach( (array) current($wp_filter[$tag]) as $the_ ) {
     168                        $args[1] = $value;
     169                        $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
     170                }
    173171        } while ( next($wp_filter[$tag]) !== false );
    174172
    175173        array_pop( $wp_current_filter );
     
    223221
    224222        do {
    225223                foreach( (array) current($wp_filter[$tag]) as $the_ )
    226                         if ( !is_null($the_['function']) )
    227                                 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    228 
     224                        $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    229225        } while ( next($wp_filter[$tag]) !== false );
    230226
    231227        array_pop( $wp_current_filter );
     
    399395
    400396        do {
    401397                foreach ( (array) current($wp_filter[$tag]) as $the_ )
    402                         if ( !is_null($the_['function']) )
    403                                 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    404 
     398                        call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    405399        } while ( next($wp_filter[$tag]) !== false );
    406400
    407401        array_pop($wp_current_filter);
     
    480474
    481475        do {
    482476                foreach( (array) current($wp_filter[$tag]) as $the_ )
    483                         if ( !is_null($the_['function']) )
    484                                 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    485 
     477                        call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    486478        } while ( next($wp_filter[$tag]) !== false );
    487479
    488480        array_pop($wp_current_filter);
     
    710702        reset( $wp_filter['all'] );
    711703        do {
    712704                foreach( (array) current($wp_filter['all']) as $the_ )
    713                         if ( !is_null($the_['function']) )
    714                                 call_user_func_array($the_['function'], $args);
    715 
     705                        call_user_func_array($the_['function'], $args);
    716706        } while ( next($wp_filter['all']) !== false );
    717707}
    718708