-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Micro-optimizations #162
base: 1.9.x
Are you sure you want to change the base?
Micro-optimizations #162
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,26 +139,29 @@ private function parseAtomic(TokenIterator $tokens): Ast\Type\TypeNode | |
$tokens->dropSavePoint(); // because of ConstFetchNode | ||
} | ||
|
||
$exception = new ParserException( | ||
$tokens->currentTokenValue(), | ||
$tokens->currentTokenType(), | ||
$tokens->currentTokenOffset(), | ||
Lexer::TOKEN_IDENTIFIER | ||
); | ||
$tokensCopy = $tokens->copy(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but I know Ondřej dislikes |
||
$exception = static function () use ($tokensCopy): ParserException { | ||
return new ParserException( | ||
$tokensCopy->currentTokenValue(), | ||
$tokensCopy->currentTokenType(), | ||
$tokensCopy->currentTokenOffset(), | ||
Lexer::TOKEN_IDENTIFIER | ||
); | ||
}; | ||
|
||
if ($this->constExprParser === null) { | ||
throw $exception; | ||
throw $exception(); | ||
} | ||
|
||
try { | ||
$constExpr = $this->constExprParser->parse($tokens, true); | ||
if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) { | ||
throw $exception; | ||
throw $exception(); | ||
} | ||
|
||
return new Ast\Type\ConstTypeNode($constExpr); | ||
} catch (LogicException $e) { | ||
throw $exception; | ||
throw $exception(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like constExprParser no longer throws |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this faster then
array_fill_keys($tokenType, true)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's indistinguishable so changing to
array_fill_keys()
is fine by me :)