Cache the result of getAmbiguousFolders until a class is added - #50
Merged
Merged
Conversation
Composer checks it both while dumping the autoloader and again in the dump-autoload command to pick the exit code, and the walk over all paths is the costly part.
Seldaek
force-pushed
the
memoize-ambiguous-folders
branch
from
September 25, 2026 15:17
9f1ffc4 to
94bcda0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caches the result of
getAmbiguousFolders()per filter value on theClassMapinstance. The cache is dropped wheneveraddClass()oraddAmbiguousClass()is called.Composer calls it twice with the same filter: once while dumping the autoloader to print warnings, and once in
dump-autoload --strict-ambiguousto pick the exit code. The walk over all paths is the expensive part, at roughly 50ms for 20k classes.Changes made by writing to the public
$mapproperty directly are not detected, so the cache is not dropped in that case. Composer only usesaddClass().