Plugins: Remove `is_object()` check in `WP_Hook:build_preinitialized_hooks()`.
This is a minor performance enhancement: * If an object is passed, the call to `is_object()` will be redundant. * If a non-object is passed, the `instanceof` operator (a variant of `is_a()`) will first [https://github.com/php/php-src/blob/f42992f/Zend/zend_builtin_functions.c#L630-L631 check if it is an object] before doing any further processing. Therefore, no additional processing cycles should be wasted in both cases. Follow-up to [38571]. Props bor0, johnbillion, davidbaumwald. Fixes #58290. Built from https://develop.svn.wordpress.org/trunk@55748 git-svn-id: http://core.svn.wordpress.org/trunk@55260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3ac5fd72d0
commit
d35d467c9c
|
@ -290,11 +290,13 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||||
$nesting_level = $this->nesting_level++;
|
$nesting_level = $this->nesting_level++;
|
||||||
|
|
||||||
$this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
|
$this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
|
||||||
$num_args = count( $args );
|
|
||||||
|
$num_args = count( $args );
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );
|
$this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );
|
||||||
$priority = $this->current_priority[ $nesting_level ];
|
|
||||||
|
$priority = $this->current_priority[ $nesting_level ];
|
||||||
|
|
||||||
foreach ( $this->callbacks[ $priority ] as $the_ ) {
|
foreach ( $this->callbacks[ $priority ] as $the_ ) {
|
||||||
if ( ! $this->doing_action ) {
|
if ( ! $this->doing_action ) {
|
||||||
|
@ -410,7 +412,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||||
$normalized = array();
|
$normalized = array();
|
||||||
|
|
||||||
foreach ( $filters as $hook_name => $callback_groups ) {
|
foreach ( $filters as $hook_name => $callback_groups ) {
|
||||||
if ( is_object( $callback_groups ) && $callback_groups instanceof WP_Hook ) {
|
if ( $callback_groups instanceof WP_Hook ) {
|
||||||
$normalized[ $hook_name ] = $callback_groups;
|
$normalized[ $hook_name ] = $callback_groups;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-55747';
|
$wp_version = '6.3-alpha-55748';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue