mirror of
https://github.com/prasathmani/tinyfilemanager
synced 2026-03-14 20:55:50 +01: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
1 changed files with 9 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue