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 committed Jun 18, 2024
1 parent 7eb922f commit acbd3cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ private function exportArray(array &$value, RecursionContext $processed, int $in
$array = $value;
$key = $processed->add($value);
$values = '';
$whitespace = str_repeat(' ', 4 * $indentation);

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

foreach ($array as $k => $v) {
$values .=
$whitespace
Expand Down Expand Up @@ -370,9 +371,10 @@ private function exportObject(object $value, RecursionContext $processed, int $i

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

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

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

0 comments on commit acbd3cb

Please sign in to comment.