1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Remove checker cache optimisation (v2 only)

This commit is contained in:
Matt Brown 2018-04-25 11:52:24 -04:00
parent d09d547718
commit 9a1674bd0e
4 changed files with 11 additions and 47 deletions

View File

@ -135,16 +135,7 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
) {
$method_id = $this->fq_class_name . '::' . $stmt->name->name;
if ($project_checker->canCacheCheckers()) {
$method_checker = $codebase->methods->getCachedChecker($method_id);
if (!$method_checker) {
$method_checker = new MethodChecker($stmt, $this);
$codebase->methods->cacheChecker($method_id, $method_checker);
}
} else {
$method_checker = new MethodChecker($stmt, $this);
}
$method_checker = new MethodChecker($stmt, $this);
$method_checker->analyze($context, null, true);
} elseif ($stmt instanceof PhpParser\Node\Stmt\TraitUse) {

View File

@ -133,11 +133,6 @@ class ProjectChecker
*/
private $file_checkers = [];
/**
* @var bool
*/
private $cache = false;
const TYPE_CONSOLE = 'console';
const TYPE_PYLINT = 'pylint';
const TYPE_JSON = 'json';
@ -660,20 +655,12 @@ class ProjectChecker
$file_path = $this->codebase->scanner->getClassLikeFilePath($fq_class_name_lc);
if ($this->cache && isset($this->file_checkers[$file_path])) {
return $this->file_checkers[$file_path];
}
$file_checker = new FileChecker(
$this,
$file_path,
$this->config->shortenFileName($file_path)
);
if ($this->cache) {
$this->file_checkers[$file_path] = $file_checker;
}
return $file_checker;
}
@ -719,28 +706,4 @@ class ProjectChecker
$file_checker->getMethodMutations($appearing_method_id, $this_context);
}
/**
* @return void
*/
public function enableCheckerCache()
{
$this->cache = true;
}
/**
* @return void
*/
public function disableCheckerCache()
{
$this->cache = false;
}
/**
* @return bool
*/
public function canCacheCheckers()
{
return $this->cache;
}
}

View File

@ -136,6 +136,8 @@ class Analyzer
}
$file_checker->analyze(null);
echo 'Current memory: ' . number_format(memory_get_usage() / (1024 * 1024), 3) . 'MB' . "\n";
};
if ($pool_size > 1 && count($this->files_to_analyze) > $pool_size) {

View File

@ -487,4 +487,12 @@ class Methods
{
$this->method_checkers[$method_id] = $checker;
}
/**
* @return void
*/
public function emptyCheckerCache()
{
$this->method_checkers[] = [];
}
}