From eb9f9167151a62759ffc9c9abb01921fb11df00d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 28 Sep 2022 01:05:50 +0200 Subject: [PATCH] Performance: remove unnecessary repeated function call 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. --- lib/experimental/html/class-wp-html-tag-processor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/experimental/html/class-wp-html-tag-processor.php b/lib/experimental/html/class-wp-html-tag-processor.php index 0d1c0756e843ca..cd6ab70ae18521 100644 --- a/lib/experimental/html/class-wp-html-tag-processor.php +++ b/lib/experimental/html/class-wp-html-tag-processor.php @@ -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 );