1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 12:47:39 +02:00

avoid function call when not needed; use single variable instead of two

This commit is contained in:
The Digital Orchard
2019-01-25 17:44:25 -08:00
parent ebb804e432
commit 0b76b0b36a
2 changed files with 12 additions and 6 deletions

View File

@@ -21,10 +21,13 @@ class MemoryPeakUsageProcessor extends MemoryProcessor
{ {
public function __invoke(array $record): array public function __invoke(array $record): array
{ {
$bytes = memory_get_peak_usage($this->realUsage); $usage = memory_get_peak_usage($this->realUsage);
$formatted = $this->formatBytes($bytes);
$record['extra']['memory_peak_usage'] = $formatted; if ($this->useFormatting) {
$usage = $this->formatBytes($usage);
}
$record['extra']['memory_peak_usage'] = $usage;
return $record; return $record;
} }

View File

@@ -21,10 +21,13 @@ class MemoryUsageProcessor extends MemoryProcessor
{ {
public function __invoke(array $record): array public function __invoke(array $record): array
{ {
$bytes = memory_get_usage($this->realUsage); $usage = memory_get_usage($this->realUsage);
$formatted = $this->formatBytes($bytes);
$record['extra']['memory_usage'] = $formatted; if ($this->useFormatting) {
$usage = $this->formatBytes($usage);
}
$record['extra']['memory_usage'] = $usage;
return $record; return $record;
} }