Skip to content

Commit a7e4403

Browse files
committed
ext/standard/file: disable the read buffer in file_get_contents()
The read buffer is useless here, it only hurts performance.
1 parent d67698a commit a7e4403

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ext/standard/file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@ PHP_FUNCTION(file_get_contents)
566566
RETURN_FALSE;
567567
}
568568

569+
/* disabling the read buffer allows doing the whole transfer
570+
in just one read() system call */
571+
php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER, PHP_STREAM_BUFFER_NONE, NULL);
572+
569573
if (offset != 0 && php_stream_seek(stream, offset, ((offset > 0) ? SEEK_SET : SEEK_END)) < 0) {
570574
php_error_docref(NULL, E_WARNING, "Failed to seek to position " ZEND_LONG_FMT " in the stream", offset);
571575
php_stream_close(stream);

0 commit comments

Comments
 (0)