diff --git a/src/Composer/IO/ConsoleIO.php b/src/Composer/IO/ConsoleIO.php index 28a2247cd..7df26eabf 100644 --- a/src/Composer/IO/ConsoleIO.php +++ b/src/Composer/IO/ConsoleIO.php @@ -96,16 +96,11 @@ class ConsoleIO extends BaseIO public function write($messages, $newline = true) { if (null !== $this->startTime) { - $messages = (array) $messages; - $startTime = $this->startTime; - $messages = array_map(function ($message) use ($startTime) { - return sprintf( - '[%.1fMB/%.2fs] %s', - memory_get_usage() / 1024 / 1024, - microtime(true) - $startTime, - $message - ); - }, $messages); + $memoryUsage = memory_get_usage() / 1024 / 1024; + $timeSpent = microtime(true) - $this->startTime; + $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) { + return sprintf('[%.1fMB/%.2fs] %s', $memoryUsage, $timeSpent, $message); + }, (array) $messages); } $this->output->write($messages, $newline); $this->lastMessage = join($newline ? "\n" : '', (array) $messages);