Skip to content

Commit

Permalink
Less_Parser: Faster skipWhitespace() by using native strspn()
Browse files Browse the repository at this point in the history
Code change similiar to fe5f50a

Change-Id: I190ca66c96a32c6386cd36eadfc8d924f14c3574
  • Loading branch information
umherirrender committed Aug 10, 2023
1 parent 1b813d6 commit 7d6bb56
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/Less/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down

0 comments on commit 7d6bb56

Please sign in to comment.