Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/Type/FileTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PHPStan\Type\Generic\TemplateTypeVariance;
use PHPStan\Type\Generic\TemplateTypeVarianceMap;
use function array_key_exists;
use function array_key_first;
use function array_keys;
use function array_map;
use function array_merge;
Expand Down Expand Up @@ -130,13 +131,7 @@ private function createResolvedPhpDocBlock(string $phpDocKey, NameScope $nameSco
{
$phpDocNode = $this->phpDocStringResolver->resolve($phpDocString);
if ($this->resolvedPhpDocBlockCacheCount >= 2048) {
$this->resolvedPhpDocBlockCache = array_slice(
$this->resolvedPhpDocBlockCache,
1,
null,
true,
);

unset($this->resolvedPhpDocBlockCache[array_key_first($this->resolvedPhpDocBlockCache)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As arrays are ordered, removing the first key is quite CPU expensive. The array should be probably reduced by 10-50% at once.

Also I am not exactly sure how only 2048 temporary copied keys can cause dramatic memory peak increase.

$this->resolvedPhpDocBlockCacheCount--;
}

Expand Down
Loading