Make WordPress Core

Changeset 55748


Ignore:
Timestamp:
05/11/2023 11:42:00 AM (13 months ago)
Author:
SergeyBiryukov
Message:

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 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.

File:
1 edited

Legend:

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

    r54133 r55748  
    291291
    292292        $this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
    293         $num_args                           = count( $args );
     293
     294        $num_args = count( $args );
    294295
    295296        do {
    296297            $this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );
    297             $priority                                 = $this->current_priority[ $nesting_level ];
     298
     299            $priority = $this->current_priority[ $nesting_level ];
    298300
    299301            foreach ( $this->callbacks[ $priority ] as $the_ ) {
     
    411413
    412414        foreach ( $filters as $hook_name => $callback_groups ) {
    413             if ( is_object( $callback_groups ) && $callback_groups instanceof WP_Hook ) {
     415            if ( $callback_groups instanceof WP_Hook ) {
    414416                $normalized[ $hook_name ] = $callback_groups;
    415417                continue;
Note: See TracChangeset for help on using the changeset viewer.