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 repeated calls to EasyCodingStandardStyle->isDebug() #194

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/FixerRunner/Application/FixerFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ final class FixerFileProcessor implements FileProcessorInterface
*/
private array $fixers = [];

private readonly bool $isDebug;

/**
* @param FixerInterface[] $fixers
*/
Expand All @@ -44,6 +46,7 @@ public function __construct(
array $fixers
) {
$this->fixers = $this->sortFixers($fixers);
$this->isDebug = $easyCodingStandardStyle->isDebug();
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 need to be applied in EasyCodingStandardApplication and File object as well?

Copy link
Contributor Author

@staabm staabm Apr 19, 2024

Choose a reason for hiding this comment

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

I did it only here to keep the PR minimal. isDebug() is not per se slow/hungry, but in this special case which is called very frequently. other occurences do not show up in profilling.

}

/**
Expand Down Expand Up @@ -148,7 +151,7 @@ private function processTokensByFixer(string $filePath, Tokens $tokens, FixerInt
}

// show current fixer in --debug / -vvv
if ($this->easyCodingStandardStyle->isDebug()) {
if ($this->isDebug) {
$this->easyCodingStandardStyle->writeln(' [fixer] ' . $fixer::class);
}

Expand Down
Loading