1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Only do partial parsing if there are few changes

This commit is contained in:
Matthew Brown 2018-10-30 22:25:31 -04:00
parent cd9e9321fd
commit 1a08b69d9c

View File

@ -123,11 +123,16 @@ class StatementsProvider
if ($existing_statements && $existing_file_contents) {
$file_changes = \Psalm\Diff\FileDiffer::getDiff($existing_file_contents, $file_contents);
$traverser = new PhpParser\NodeTraverser;
$traverser->addVisitor(new \Psalm\Visitor\CloningVisitor);
// performs a deep clone
/** @var array<int, PhpParser\Node\Stmt> */
$existing_statements_copy = $traverser->traverse($existing_statements);
if (count($file_changes) < 10) {
$traverser = new PhpParser\NodeTraverser;
$traverser->addVisitor(new \Psalm\Visitor\CloningVisitor);
// performs a deep clone
/** @var array<int, PhpParser\Node\Stmt> */
$existing_statements_copy = $traverser->traverse($existing_statements);
} else {
$file_changes = null;
}
}
$stmts = self::parseStatements(