Skip to content

Commit

Permalink
Improve memory efficiency
Browse files Browse the repository at this point in the history
This avoids concatenating `$message` and `PHP_EOL` (if necessary) as a new value, greatly improving memory efficiency for large `$message`s.
  • Loading branch information
Dword123 committed Jun 1, 2016
1 parent 00763f6 commit c1df9f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Output/StreamOutput.php
Expand Up @@ -70,7 +70,7 @@ public function getStream()
*/
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
throw new \RuntimeException('Unable to write output.');
}
Expand Down

0 comments on commit c1df9f2

Please sign in to comment.