Improve do_action performance. Make an associative array. Props koopersmith. fixes #10561
git-svn-id: http://svn.automattic.com/wordpress/trunk@12464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9fa732df33
commit
7b00fcb9f6
|
@ -299,10 +299,13 @@ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
||||||
function do_action($tag, $arg = '') {
|
function do_action($tag, $arg = '') {
|
||||||
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
|
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
|
||||||
|
|
||||||
if ( is_array($wp_actions) )
|
if ( ! isset($wp_actions) )
|
||||||
$wp_actions[] = $tag;
|
$wp_actions = array();
|
||||||
|
|
||||||
|
if ( ! isset($wp_actions[$tag]) )
|
||||||
|
$wp_actions[$tag] = 1;
|
||||||
else
|
else
|
||||||
$wp_actions = array($tag);
|
++$wp_actions[$tag];
|
||||||
|
|
||||||
$wp_current_filter[] = $tag;
|
$wp_current_filter[] = $tag;
|
||||||
|
|
||||||
|
@ -357,10 +360,10 @@ function do_action($tag, $arg = '') {
|
||||||
function did_action($tag) {
|
function did_action($tag) {
|
||||||
global $wp_actions;
|
global $wp_actions;
|
||||||
|
|
||||||
if ( empty($wp_actions) )
|
if ( ! isset( $wp_actions ) || ! isset( $wp_actions[$tag] ) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return count(array_keys($wp_actions, $tag));
|
return $wp_actions[$tag];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -382,10 +385,13 @@ function did_action($tag) {
|
||||||
function do_action_ref_array($tag, $args) {
|
function do_action_ref_array($tag, $args) {
|
||||||
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
|
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
|
||||||
|
|
||||||
if ( !is_array($wp_actions) )
|
if ( ! isset($wp_actions) )
|
||||||
$wp_actions = array($tag);
|
$wp_actions = array();
|
||||||
|
|
||||||
|
if ( ! isset($wp_actions[$tag]) )
|
||||||
|
$wp_actions[$tag] = 1;
|
||||||
else
|
else
|
||||||
$wp_actions[] = $tag;
|
++$wp_actions[$tag];
|
||||||
|
|
||||||
$wp_current_filter[] = $tag;
|
$wp_current_filter[] = $tag;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue