From 7d6bb56dc284c8d9fbaa86fed74e0e6240dba13e Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Fri, 11 Aug 2023 01:06:41 +0200 Subject: [PATCH] Less_Parser: Faster skipWhitespace() by using native strspn() Code change similiar to fe5f50aa Change-Id: I190ca66c96a32c6386cd36eadfc8d924f14c3574 --- lib/Less/Parser.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/Less/Parser.php b/lib/Less/Parser.php index e1c915c6..e4690f37 100644 --- a/lib/Less/Parser.php +++ b/lib/Less/Parser.php @@ -840,14 +840,8 @@ public function PeekChar( $tok ) { */ public function skipWhitespace( $length ) { $this->pos += $length; - - for ( ; $this->pos < $this->input_len; $this->pos++ ) { - $c = $this->input[$this->pos]; - - if ( ( $c !== "\n" ) && ( $c !== "\r" ) && ( $c !== "\t" ) && ( $c !== ' ' ) ) { - break; - } - } + // Optimization: Skip over irrelevant chars without slow loop + $this->pos += strspn( $this->input, "\n\r\t ", $this->pos ); } /**