Move array_diff / array_values into different lines in MD_STD::scandir

This leads a significant reduction in RAM usage.
This commit is contained in:
Joshua Ramon Enslin 2020-11-09 14:17:54 +01:00 committed by Stefan Rohde-Enslin
parent aa67de1e54
commit 8e3d97aa7f
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -63,7 +63,13 @@ final class MD_STD {
throw new MDFileDoesNotExist("There is no file {$filepath}");
}
return \array_values(\array_diff($output, ['.', '..', '.git']));
// Remove unwanted files from list
$output = \array_diff($output, ['.', '..', '.git']);
// Return array values, to make it a list rather than an associative array.
// This should be done in a separate line, as it observably leads to a
// significant reduction in the used RAM.
return \array_values($output);
}