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

NameImportingPhpDocNodeVisitor: Cheap checks first #4563

Merged
merged 3 commits into from
Jul 21, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 21, 2023

shouldSkipNameForFullyQualifiedObjectType shows up in profiles, which means it is slow. lets move it after some very fast checks

@staabm staabm requested a review from TomasVotruba as a code owner July 21, 2023 08:03
@@ -112,26 +118,13 @@ private function processFqnNameImport(
return null;
}

$parentNode = $identifierTypeNode->getAttribute(PhpDocAttributeKey::PARENT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do this check earlier, as it is fast

$newNode = new IdentifierTypeNode($fullyQualifiedObjectType->getShortName());

// should skip because its already used
if ($this->useNodesToAddCollector->isShortImported($file, $fullyQualifiedObjectType)) {
if (! $this->useNodesToAddCollector->isImportShortable($file, $fullyQualifiedObjectType)) {
return null;
}

if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the block deleted is identical to the one after the outer IF statement

@samsonasik samsonasik merged commit d17ef04 into rectorphp:main Jul 21, 2023
@samsonasik
Copy link
Member

Thank you @staabm

@staabm staabm deleted the cheap-first branch July 21, 2023 08:24
@TomasVotruba
Copy link
Member

Thanks Markus 👏

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.

3 participants