Skip to content

Commit cad9d21

Browse files
committed
Avoid unnecessary parser lookahead reads
1 parent 0fc8ff8 commit cad9d21

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,13 @@ private function parse_recursive( $rule_id ) {
127127
// for right-associative rules, which could solve this.
128128
// See: https://github.com/mysql/mysql-workbench/blob/8.0.38/library/parsers/grammars/MySQLParser.g4#L994
129129
// See: https://github.com/antlr/antlr4/issues/488
130-
$lookahead_id = $this->position < $this->token_count
131-
? $this->token_ids[ $this->position ]
132-
: null;
133-
if (
134-
null !== $lookahead_id
135-
&& $rule_id === $this->select_statement_rule_id
136-
&& WP_MySQL_Lexer::INTO_SYMBOL === $lookahead_id
137-
) {
138-
$branch_matches = false;
130+
if ( $rule_id === $this->select_statement_rule_id ) {
131+
$lookahead_id = $this->position < $this->token_count
132+
? $this->token_ids[ $this->position ]
133+
: null;
134+
if ( WP_MySQL_Lexer::INTO_SYMBOL === $lookahead_id ) {
135+
$branch_matches = false;
136+
}
139137
}
140138

141139
if ( true === $branch_matches ) {

0 commit comments

Comments
 (0)