Skip to content

Commit

Permalink
Reading list of inc files: performance improvements (fewer popen)
Browse files Browse the repository at this point in the history
  • Loading branch information
plepe committed Jul 8, 2017
1 parent 530aa43 commit 3726732
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions loader.php
Expand Up @@ -33,13 +33,21 @@ function modulekit_process_inc_files($basepath, $include) {
foreach($include as $type=>$list) {
$ret[$type] = array();

if (!sizeof($list)) {
continue;
}

$cmd = "cd " . escapeshellarg($modulekit_root . $basepath) . " 2>/dev/null";

foreach ($list as $type_list) {
$f = popen("cd " . escapeshellarg($modulekit_root . $basepath) . " 2>/dev/null; ls " . escapeshellarg($type_list) . " 2>/dev/null", "r");
while ($r = fgets($f)) {
$ret[$type][] = trim($r);
}
fclose($f);
$cmd .= "; ls " . escapeshellarg($type_list) . " 2>/dev/null";
}

$f = popen($cmd, "r");
while ($r = fgets($f)) {
$ret[$type][] = trim($r);
}
fclose($f);
}

return $ret;
Expand Down

0 comments on commit 3726732

Please sign in to comment.