Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Dec 9, 2022

remove file IO when not necessary. the IO subsystem can be super slow or at least performance can vary a lot dependent on when/where you read data from

grafik

return null;
}

$cacheItem = @include $filePath;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since we already swallow possible errors and validate the result we read just after that, we don't need to check beforehand whether $filePath actually is a file.

$filename = $this->declaringTrait->getFileName();
}

if (!$isNativelyVariadic && $filename !== null && is_file($filename)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

filemtime will return false when $filename is not a file. the code already handles this case.

lets drop this unnecessary file IO

@staabm staabm marked this pull request as ready for review December 9, 2022 15:54
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes
Copy link
Member

What's the command you're profiling this with?

@staabm
Copy link
Contributor Author

staabm commented Dec 9, 2022

blackfire run php bin/phpstan -vvv --debug

it is compared against phpstan 1.9.x @ da8413c

@ondrejmirtes ondrejmirtes merged commit 062c456 into phpstan:1.9.x Dec 9, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the fileio branch December 9, 2022 16:16
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