ruff
75e3aa36 - [ty] Avoid cubic narrowing for enum OR patterns (#30019)

Commit
25 days ago
[ty] Avoid cubic narrowing for enum OR patterns (#30019) Matching `self` against large OR patterns of enum members took cubic time. ty rebuilt a growing set of member exclusions after each alternative. When the subject and alternatives belong to the same enum and equality corresponds to member identity, ty now subtracts the matched members together. This lets ty check exhaustiveness and narrow `self` in later cases without rebuilding the exclusions for each alternative. Closes astral-sh/ty#4893. ## Test plan I reran the original `StrEnum` reproducer on the base and on this change using the same optimized debug build settings. Both revisions reported no diagnostics. | Enum members | Before | After | | ---: | ---: | ---: | | 300 | 0.47 s | 0.04 s | | 600 | 3.35 s | 0.05 s | | 1,200 | 26.44 s | 0.11 s |
Author
Parents
Loading