Skip to content

Commit 8ba293f

Browse files
committed
Skip parent constructor in WP_MySQL_Token
Token construction is on the lexer hot path; bypassing the `WP_Parser_Token::__construct()` indirection and assigning the four properties directly removes one method call per token. Requires `$input` on `WP_Parser_Token` to be `protected` instead of `private` so the subclass can write to it. Co-authored-by: Adam Zieliński <adam@adamziel.com> Adapted from #375
1 parent 1fea401 commit 8ba293f

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/mysql-on-sqlite/src/mysql/class-wp-mysql-token.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public function __construct(
3030
string $input,
3131
bool $sql_mode_no_backslash_escapes_enabled
3232
) {
33-
parent::__construct( $id, $start, $length, $input );
33+
$this->id = $id;
34+
$this->start = $start;
35+
$this->length = $length;
36+
$this->input = $input;
37+
3438
$this->sql_mode_no_backslash_escapes_enabled = $sql_mode_no_backslash_escapes_enabled;
3539
}
3640

packages/mysql-on-sqlite/src/parser/class-wp-parser-token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class WP_Parser_Token {
3535
*
3636
* @var string
3737
*/
38-
private $input;
38+
protected $input;
3939

4040
/**
4141
* Constructor.

0 commit comments

Comments
 (0)