mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Only repopulate the storage we care about
Big reduction on population time for single file edits
This commit is contained in:
parent
a41c5c8a39
commit
2b6df3658c
@ -77,7 +77,7 @@ class Populator
|
||||
echo 'ClassLikeStorage is populating' . "\n";
|
||||
}
|
||||
|
||||
foreach ($this->classlike_storage_provider->getAll() as $class_storage) {
|
||||
foreach ($this->classlike_storage_provider->getNew() as $class_storage) {
|
||||
if (!$class_storage->user_defined && !$class_storage->stubbed) {
|
||||
continue;
|
||||
}
|
||||
@ -93,14 +93,13 @@ class Populator
|
||||
echo 'FileStorage is populating' . "\n";
|
||||
}
|
||||
|
||||
$all_file_storage = $this->file_storage_provider->getAll();
|
||||
$all_file_storage = $this->file_storage_provider->getNew();
|
||||
|
||||
foreach ($all_file_storage as $file_storage) {
|
||||
$this->populateFileStorage($file_storage);
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->classlike_storage_provider->getAll() as $class_storage) {
|
||||
foreach ($this->classlike_storage_provider->getNew() as $class_storage) {
|
||||
if ($this->config->allow_phpstorm_generics) {
|
||||
foreach ($class_storage->properties as $property_storage) {
|
||||
if ($property_storage->type) {
|
||||
@ -182,6 +181,9 @@ class Populator
|
||||
if ($this->debug_output) {
|
||||
echo 'FileStorage is populated' . "\n";
|
||||
}
|
||||
|
||||
$this->classlike_storage_provider->populated();
|
||||
$this->file_storage_provider->populated();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,11 @@ class ClassLikeStorageProvider
|
||||
*/
|
||||
private static $storage = [];
|
||||
|
||||
/**
|
||||
* @var array<string, ClassLikeStorage>
|
||||
*/
|
||||
private static $new_storage = [];
|
||||
|
||||
/**
|
||||
* @var ?ClassLikeStorageCacheProvider
|
||||
*/
|
||||
@ -69,9 +74,10 @@ class ClassLikeStorageProvider
|
||||
throw new \LogicException('Cannot exhume when there’s no cache');
|
||||
}
|
||||
|
||||
self::$storage[$fq_classlike_name_lc]
|
||||
= $cached_value
|
||||
= $this->cache->getLatestFromCache($fq_classlike_name_lc, $file_path, $file_contents);
|
||||
$cached_value = $this->cache->getLatestFromCache($fq_classlike_name_lc, $file_path, $file_contents);
|
||||
|
||||
self::$storage[$fq_classlike_name_lc] = $cached_value;
|
||||
self::$new_storage[$fq_classlike_name_lc] = $cached_value;
|
||||
|
||||
return $cached_value;
|
||||
}
|
||||
@ -84,12 +90,21 @@ class ClassLikeStorageProvider
|
||||
return self::$storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, ClassLikeStorage>
|
||||
*/
|
||||
public function getNew()
|
||||
{
|
||||
return self::$new_storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, ClassLikeStorage> $more
|
||||
* @return void
|
||||
*/
|
||||
public function addMore(array $more)
|
||||
{
|
||||
self::$new_storage = array_merge($more, self::$new_storage);
|
||||
self::$storage = array_merge($more, self::$storage);
|
||||
}
|
||||
|
||||
@ -102,7 +117,9 @@ class ClassLikeStorageProvider
|
||||
{
|
||||
$fq_classlike_name_lc = strtolower($fq_classlike_name);
|
||||
|
||||
self::$storage[$fq_classlike_name_lc] = $storage = new ClassLikeStorage($fq_classlike_name);
|
||||
$storage = new ClassLikeStorage($fq_classlike_name);
|
||||
self::$storage[$fq_classlike_name_lc] = $storage;
|
||||
self::$new_storage[$fq_classlike_name_lc] = $storage;
|
||||
|
||||
return $storage;
|
||||
}
|
||||
@ -124,4 +141,12 @@ class ClassLikeStorageProvider
|
||||
{
|
||||
self::$storage = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function populated()
|
||||
{
|
||||
self::$new_storage = [];
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,14 @@ class FileStorageProvider
|
||||
*/
|
||||
private static $storage = [];
|
||||
|
||||
/**
|
||||
* A list of data useful to analyse new files
|
||||
* Storing this statically is much faster (at least in PHP 7.2.1)
|
||||
*
|
||||
* @var array<string, FileStorage>
|
||||
*/
|
||||
private static $new_storage = [];
|
||||
|
||||
/**
|
||||
* @var ?FileStorageCacheProvider
|
||||
*/
|
||||
@ -74,6 +82,7 @@ class FileStorageProvider
|
||||
}
|
||||
|
||||
self::$storage[$file_path] = $cached_value;
|
||||
self::$new_storage[$file_path] = $cached_value;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -86,12 +95,21 @@ class FileStorageProvider
|
||||
return self::$storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, FileStorage>
|
||||
*/
|
||||
public function getNew()
|
||||
{
|
||||
return self::$new_storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, FileStorage> $more
|
||||
* @return void
|
||||
*/
|
||||
public function addMore(array $more)
|
||||
{
|
||||
self::$new_storage = array_merge($more, self::$new_storage);
|
||||
self::$storage = array_merge($more, self::$storage);
|
||||
}
|
||||
|
||||
@ -104,7 +122,9 @@ class FileStorageProvider
|
||||
{
|
||||
$file_path_lc = strtolower($file_path);
|
||||
|
||||
self::$storage[$file_path_lc] = $storage = new FileStorage($file_path);
|
||||
$storage = new FileStorage($file_path);
|
||||
self::$storage[$file_path_lc] = $storage;
|
||||
self::$new_storage[$file_path_lc] = $storage;
|
||||
|
||||
return $storage;
|
||||
}
|
||||
@ -116,4 +136,12 @@ class FileStorageProvider
|
||||
{
|
||||
self::$storage = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function populated()
|
||||
{
|
||||
self::$new_storage = [];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user