Skip to content

Commit

Permalink
minor #18932 Improve memory efficiency (Dword123)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

Improve memory efficiency

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This avoids concatenating `$message` and `PHP_EOL` (if necessary) as a new value, greatly improving memory efficiency for large `$message`s.

Commits
-------

c1df9f2 Improve memory efficiency
  • Loading branch information
nicolas-grekas committed Jun 3, 2016
2 parents 9d79a40 + c1df9f2 commit a004fc7
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 a004fc7

Please sign in to comment.