Repository navigation
fix(compose): skip the lowered-environment allocation in envResolverWithCase - #14390
Merged
Merged
Conversation
…ithCase envResolverWithCase unconditionally built a lower-cased copy of the whole environment map before any lookup, even when every lookup hits a key directly. Fall back to a case-insensitive scan (strings.EqualFold) of the original map only when the exact lookup misses, so the common path allocates nothing. Folded-key conflicts (e.g. FOO and foo both present) were already documented as indefinite and remain so. Signed-off-by: Aucoto <tdnorthgarden@gmail.com>
ndeloof
approved these changes
Oct 26, 2026
ndeloof
left a comment
Contributor
There was a problem hiding this comment.
LGTM. I checked the branch locally: exact match keeps precedence and the folded fallback behaves as before for non-conflicting keys.
Non-blocking note: when two keys differ only by case (e.g. FOO and foo), the value picked is still "indefinite" as documented, but it is now chosen per lookup rather than once per resolver (map iteration order), so the same resolver can return either value across calls. Fine given the documented contract and how rare the case is; no change requested.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Problem
On the case-insensitive path (Windows),
envResolverWithCasebuilds alower-cased copy of the whole environment map up front, before any lookup
happens — even when every lookup ends up hitting a key directly. That is an
unconditional
len(environment)allocation per resolver, paid beforeknowing whether the fallback is ever needed.
Fix
As suggested by @thaJeztah in #14388:
strings.EqualFold—no copy, nothing allocated on the common path;
FOOandfooboth set) were alreadydocumented as indefinite and stay so: the test now pins that contract
(a folded lookup resolves, to one of the folded values) and the
exact-match precedence over folded keys.