wppaste
WordPress

Features::get_item_features( int $target_item_id, int $tile_depth ): Avifinfo\Status

Source
wp-includes/class-avif-info.php:130
Binds the width, height, bit depth and number of channels from stored internal features.

Compatibility

WordPress
core
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$target_item_idint
Id of the item whose features will be bound.
$tile_depthint
Maximum recursion to search within tile-parent relations.

Return value

Avifinfo\Status
FOUND on success or NOT_FOUND on failure.

Performance profile

How much work a call to Features::get_item_features() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
9–86

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 116.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What one call costs · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost Features::get_item_features() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always9–86none
$tile_depth && $target_item_id == false && $status != false25–26->get_item_features()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1169–8623
8.51169–8623
8.41169–8623
8.31169–8623
8.21169–8623
8.11169–86231 fewer instruction than PHP 7.4
7.41179–8623

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 1

  • \Avifinfo\Features::get_item_features()

Source code

  private function get_item_features( $target_item_id, $tile_depth ) {    foreach ( $this->props as $prop ) {      if ( $prop->item_id != $target_item_id ) {        continue;      }       // Retrieve the width and height of the primary item if not already done.      if ( $target_item_id == $this->primary_item_id &&           ( $this->primary_item_features['width'] == UNDEFINED ||             $this->primary_item_features['height'] == UNDEFINED ) ) {        foreach ( $this->dim_props as $dim_prop ) {          if ( $dim_prop->property_index != $prop->property_index ) {            continue;          }          $this->primary_item_features['width']  = $dim_prop->width;          $this->primary_item_features['height'] = $dim_prop->height;          if ( $this->primary_item_features['bit_depth'] != UNDEFINED &&               $this->primary_item_features['num_channels'] != UNDEFINED ) {            return FOUND;          }          break;        }      }      // Retrieve the bit depth and number of channels of the target item if not      // already done.      if ( $this->primary_item_features['bit_depth'] == UNDEFINED ||           $this->primary_item_features['num_channels'] == UNDEFINED ) {        foreach ( $this->chan_props as $chan_prop ) {          if ( $chan_prop->property_index != $prop->property_index ) {            continue;          }          $this->primary_item_features['bit_depth']    = $chan_prop->bit_depth;          $this->primary_item_features['num_channels'] = $chan_prop->num_channels;          if ( $this->primary_item_features['width'] != UNDEFINED &&              $this->primary_item_features['height'] != UNDEFINED ) {            return FOUND;          }          break;        }      }    }     // Check for the bit_depth and num_channels in a tile if not yet found.    if ( $tile_depth < 3 ) {      foreach ( $this->tiles as $tile ) {        if ( $tile->parent_item_id != $target_item_id ) {          continue;        }        $status = $this->get_item_features( $tile->tile_item_id, $tile_depth + 1 );        if ( $status != NOT_FOUND ) {          return $status;        }      }    }    return NOT_FOUND;  }

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/class-avif-info.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.