1
0
Fork 0

Optimize processFile() a bit

pull/31/head
Felix Becker 2016-09-29 19:59:23 +02:00
parent fa9e540c47
commit 38c8cac7c7
1 changed files with 7 additions and 7 deletions

View File

@ -133,20 +133,20 @@ class LanguageServer extends \AdvancedJsonRpc\Dispatcher
$numTotalFiles = count($fileList); $numTotalFiles = count($fileList);
$startTime = microtime(true); $startTime = microtime(true);
$fileNum = 0;
$processFile = function() use (&$fileList, &$processFile, $rootPath, $numTotalFiles, $startTime) { $processFile = function() use (&$fileList, &$fileNum, &$processFile, $rootPath, $numTotalFiles, $startTime) {
if ($file = array_pop($fileList)) { if ($fileNum < $numTotalFiles) {
$file = $fileList[$fileNum];
$uri = pathToUri($file); $uri = pathToUri($file);
$fileNum = $numTotalFiles - count($fileList); $fileNum++;
$shortName = substr($file, strlen($rootPath)+1); $shortName = substr($file, strlen($rootPath) + 1);
$this->client->window->logMessage(3, "Parsing file $fileNum/$numTotalFiles: $shortName."); $this->client->window->logMessage(3, "Parsing file $fileNum/$numTotalFiles: $shortName.");
$this->project->getDocument($uri)->updateContent(file_get_contents($file)); $this->project->getDocument($uri)->updateContent(file_get_contents($file));
Loop\setTimeout($processFile, 0); Loop\setTimeout($processFile, 0);
} } else {
else {
$duration = (int)(microtime(true) - $startTime); $duration = (int)(microtime(true) - $startTime);
$mem = (int)(memory_get_usage(true) / (1024 * 1024)); $mem = (int)(memory_get_usage(true) / (1024 * 1024));
$this->client->window->logMessage(3, "All PHP files parsed in $duration seconds. $mem MiB allocated."); $this->client->window->logMessage(3, "All PHP files parsed in $duration seconds. $mem MiB allocated.");