Skip to content

Commit 010e235

Browse files
committed
Using a less expensive operation to check if the buffer has reached it's limit
1 parent 71530c0 commit 010e235

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function buffer(ReadableStreamInterface $stream, $maxLength = null)
2626
$buffer = '';
2727
$bufferer = function ($data) use (&$buffer, &$bufferer, $stream, $deferred, $maxLength) {
2828
$buffer .= $data;
29-
if ($maxLength !== null && strlen($buffer) > (int)$maxLength) {
29+
if ($maxLength !== null && isset($buffer[$maxLength])) {
3030
$deferred->reject(new \RuntimeException('Buffer exceeded maximum length'));
3131
}
3232
};

0 commit comments

Comments
 (0)