mirror of
https://github.com/prasathmani/tinyfilemanager.git
synced 2025-05-05 14:55:57 +02:00
reduce feof() calls (#1041)
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
f7a2f77008
@ -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…
x
Reference in New Issue
Block a user