-
Notifications
You must be signed in to change notification settings - Fork 63
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
Conversation
@@ -160,8 +161,10 @@ public function getSkippedHorizontalWhiteSpaceIfAny(): string | |||
/** @phpstan-impure */ | |||
public function joinUntil(int ...$tokenType): string | |||
{ | |||
$tokenTypeMap = array_flip($tokenType); |
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 :)
$tokens->currentTokenOffset(), | ||
Lexer::TOKEN_IDENTIFIER | ||
); | ||
$tokensCopy = $tokens->copy(); |
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.
Can you not just clone $tokens
?
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.
Yes, but I know Ondřej dislikes clone
} | ||
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like constExprParser no longer throws LogicException
since d8e9fd9.
@rvanvelzen do you have a benchmark or a concrete scenario/code-example where these changes help perf wise? |
d25945f
to
57f6787
Compare
No description provided.