Skip to content

Commit

Permalink
Prevent unnecessary calls to str_repeat()
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and sebastianbergmann committed Jun 18, 2024
1 parent 8474a9e commit 09fec25
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,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);
$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 @@ -371,11 +372,12 @@ private function exportObject(object $value, RecursionContext $processed, int $i

$processed->add($value);

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

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

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

0 comments on commit 09fec25

Please sign in to comment.