mirror of
https://github.com/prasathmani/tinyfilemanager
synced 2024-06-08 08:52:23 +02:00
reduce feof() calls
micro-optimization: when doing large file copies, this will reduce the number of feof() calls. for example, if copying 100MB, this will save approximately 25,599 feof() calls (255 feof() calls for every MB) - also feofs() may do an actual syscall, and syscalls are relatively expensive/time-consuming.
This commit is contained in:
parent
dabc4ea36e
commit
1ddbe9cbd7
|
@ -971,7 +971,15 @@ if (!empty($_FILES) && !FM_READONLY) {
|
|||
if ($in) {
|
||||
if (PHP_VERSION_ID < 80009) {
|
||||
// workaround https://bugs.php.net/bug.php?id=81145
|
||||
while (!feof($in)) { fwrite($out, fread($in, 4096)); }
|
||||
do {
|
||||
for (;;) {
|
||||
$buff = fread($in, 4096);
|
||||
if ($buff === false || $buff === '') {
|
||||
break;
|
||||
}
|
||||
fwrite($out, $buff);
|
||||
}
|
||||
} while (!feof($in));
|
||||
} else {
|
||||
stream_copy_to_stream($in, $out);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue