Improve memory efficiency

This avoids concatenating `$message` and `PHP_EOL` (if necessary) as a new value, greatly improving memory efficiency for large `$message`s.
This commit is contained in:
Dword123 2016-06-01 13:20:21 +02:00
parent 00763f6e41
commit c1df9f210e

View File

@ -70,7 +70,7 @@ class StreamOutput extends Output
*/ */
protected function doWrite($message, $newline) protected function doWrite($message, $newline)
{ {
if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) { if (false === @fwrite($this->stream, $message) || ($newline && (false === @fwrite($this->stream, PHP_EOL)))) {
// should never happen // should never happen
throw new \RuntimeException('Unable to write output.'); throw new \RuntimeException('Unable to write output.');
} }