Skip to content

Commit

Permalink
Optimization - do not sort huge unions
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Aug 22, 2021
1 parent 89ceb6a commit 5a44c29
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Type/UnionTypeHelper.php
Expand Up @@ -32,6 +32,10 @@ public static function getReferencedClasses(array $types): array
*/
public static function sortTypes(array $types): array
{
if (count($types) > 1024) {
return $types;
}

usort($types, static function (Type $a, Type $b): int {
if ($a instanceof NullType) {
return 1;
Expand Down

0 comments on commit 5a44c29

Please sign in to comment.