From 8e3d97aa7fe031ecedd83d298e9d50329263989b Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 9 Nov 2020 14:17:54 +0100 Subject: [PATCH] Move array_diff / array_values into different lines in MD_STD::scandir This leads a significant reduction in RAM usage. --- MD_STD.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MD_STD.php b/MD_STD.php index fe93d44..2313e4a 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -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); }