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

Remove unnecessary IO #2613

Merged
merged 4 commits into from Sep 29, 2023
Merged

Remove unnecessary IO #2613

merged 4 commits into from Sep 29, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 9, 2023

re-submit less controversial part of #2596


we don't need this is_file call (and also not the one below for is_dir), because of

$classMapFiles = array_filter($classMapPaths, 'is_file');
$classMapDirectories = array_filter($classMapPaths, 'is_dir');

above

@staabm staabm force-pushed the lessIO branch 2 times, most recently from fad620f to d8ae564 Compare September 13, 2023 15:27
foreach (array_merge($classMapFiles, $filePaths) as $file) {
if (!is_file($file)) {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

What about checking is_file for $filePaths here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed.

Copy link
Member

Choose a reason for hiding this comment

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

How is this change different to what already happened to previous version of the code?

Copy link
Contributor Author

@staabm staabm Sep 29, 2023

Choose a reason for hiding this comment

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

before this PR, every path in classMapPaths was checked twice via is_dir / is_file. after the PR only once.

Copy link
Member

Choose a reason for hiding this comment

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

Screenshot 2023-09-29 at 14 27 14

See the diff screenshot - I'd rather have the is_file / is_dir calls in foreaches than the array_filter calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh I see. I read your initial comment differently.

just reworked the code to get rid of array_filter().

@ondrejmirtes ondrejmirtes merged commit 65cda8b into phpstan:1.10.x Sep 29, 2023
376 of 378 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the lessIO branch September 29, 2023 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants