Skip to content

Commit

Permalink
Performance: remove unnecessary repeated function call
Browse files Browse the repository at this point in the history
The length of the `$existing_class` does not change within the loop, so it is completely redundant and inefficient to recalculate the length for every loop.
  • Loading branch information
jrfnl committed Sep 28, 2022
1 parent 74b0377 commit eb9f916
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/experimental/html/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,8 @@ private function class_name_updates_to_attributes_updates() {
$modified = false;

// Remove unwanted classes by only copying the new ones.
while ( $at < strlen( $existing_class ) ) {
$existing_class_length = strlen( $existing_class );
while ( $at < $existing_class_length ) {
// Skip to the first non-whitespace character.
$ws_at = $at;
$ws_length = strspn( $existing_class, " \t\f\r\n", $ws_at );
Expand Down

0 comments on commit eb9f916

Please sign in to comment.