Skip to content

Commit d82a30e

Browse files
committed
main/streams/streams: check php_stream_eof() before php_stream_read()
This eliminates the last redundant read() system call in every file_get_contents() call.
1 parent 7e9fa75 commit d82a30e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main/streams/streams.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
15171517
ptr = ZSTR_VAL(result);
15181518

15191519
// TODO: Propagate error?
1520-
while ((ret = php_stream_read(src, ptr, max_len - len)) > 0){
1520+
while (!php_stream_eof(src) && (ret = php_stream_read(src, ptr, max_len - len)) > 0){
15211521
len += ret;
15221522
if (len + min_room >= max_len) {
15231523
result = zend_string_extend(result, max_len + step, persistent);

0 commit comments

Comments
 (0)