minor #18932 Improve memory efficiency (Dword123)
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
This commit is contained in:
commit
a004fc7526
@ -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.');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user