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

Prevent unnecessary calls to str_repeat() #65

Merged
merged 1 commit into from
Jun 18, 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
16 changes: 9 additions & 7 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,13 @@ private function exportArray(array &$value, RecursionContext $processed, int $in
return 'Array &' . $key;
}

$array = $value;
$key = $processed->add($value);
$values = '';
$whitespace = str_repeat(' ', 4 * $indentation);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved this line into the lower if. everything else is cs-fixer doing its thing

$array = $value;
$key = $processed->add($value);
$values = '';

if (count($array) > 0) {
$whitespace = str_repeat(' ', 4 * $indentation);

foreach ($array as $k => $v) {
$values .=
$whitespace
Expand All @@ -368,11 +369,12 @@ private function exportObject(object $value, RecursionContext $processed, int $i

$processed->add($value);

$array = $this->toArray($value);
$buffer = '';
$whitespace = str_repeat(' ', 4 * $indentation);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above

$array = $this->toArray($value);
$buffer = '';

if (count($array) > 0) {
$whitespace = str_repeat(' ', 4 * $indentation);

foreach ($array as $k => $v) {
$buffer .=
$whitespace
Expand Down