diff --git a/src/Tokenizer/Token.php b/src/Tokenizer/Token.php index 1fdb8601ccc..0ae3fdc1ca7 100644 --- a/src/Tokenizer/Token.php +++ b/src/Tokenizer/Token.php @@ -156,7 +156,21 @@ public function clearChanged() */ public function equals($other, $caseSensitive = true) { - $otherPrototype = $other instanceof self ? $other->getPrototype() : $other; + if ($other instanceof self) { + // Inlined getPrototype() on this very hot path. + // We access the private properties of $other directly to save function call overhead. + // This is only possible because $other is of the same class as `self`. + if (!$other->isArray) { + $otherPrototype = $other->content; + } else { + $otherPrototype = [ + $other->id, + $other->content, + ]; + } + } else { + $otherPrototype = $other; + } if ($this->isArray !== \is_array($otherPrototype)) { return false;