Make WordPress Core


Ignore:
Timestamp:
12/21/2009 08:47:34 AM (15 years ago)
Author:
ryan
Message:

Improve do_action performance. Make an associative array. Props koopersmith. fixes #10561

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/plugin.php

    r12090 r12464  
    300300    global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
    301301
    302     if ( is_array($wp_actions) )
    303         $wp_actions[] = $tag;
     302    if ( ! isset($wp_actions) )
     303        $wp_actions = array();
     304   
     305    if ( ! isset($wp_actions[$tag]) )
     306        $wp_actions[$tag] = 1;
    304307    else
    305         $wp_actions = array($tag);
     308        ++$wp_actions[$tag];
    306309
    307310    $wp_current_filter[] = $tag;
     
    358361    global $wp_actions;
    359362
    360     if ( empty($wp_actions) )
     363    if ( ! isset( $wp_actions ) || ! isset( $wp_actions[$tag] ) )
    361364        return 0;
    362365
    363     return count(array_keys($wp_actions, $tag));
     366    return $wp_actions[$tag];
    364367}
    365368
     
    383386    global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
    384387
    385     if ( !is_array($wp_actions) )
    386         $wp_actions = array($tag);
     388    if ( ! isset($wp_actions) )
     389        $wp_actions = array();
     390   
     391    if ( ! isset($wp_actions[$tag]) )
     392        $wp_actions[$tag] = 1;
    387393    else
    388         $wp_actions[] = $tag;
     394        ++$wp_actions[$tag];
    389395
    390396    $wp_current_filter[] = $tag;
Note: See TracChangeset for help on using the changeset viewer.