Skip to content
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

Open
wants to merge 3 commits into
base: 1.9.x
Choose a base branch
from
Open

Conversation

rvanvelzen
Copy link
Contributor

No description provided.

@@ -160,8 +161,10 @@ public function getSkippedHorizontalWhiteSpaceIfAny(): string
/** @phpstan-impure */
public function joinUntil(int ...$tokenType): string
{
$tokenTypeMap = array_flip($tokenType);
Copy link
Collaborator

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)?

Copy link
Contributor Author

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();
Copy link
Collaborator

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?

Copy link
Contributor Author

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();
Copy link
Collaborator

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.

@staabm
Copy link
Contributor

staabm commented Nov 21, 2022

@rvanvelzen do you have a benchmark or a concrete scenario/code-example where these changes help perf wise?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants