Repository navigation
fix: preserve gaps in envPrefix slice indices - #437
Open
team-humaki wants to merge 1 commit into
Open
team-humaki wants to merge 1 commit into
team-humaki wants to merge 1 commit into
Conversation
doParseSlice previously stopped at the first missing index, so FOO_0 / FOO_2 / FOO_3 only loaded through the gap. Scan for the max numeric index under the prefix and size the slice to max+1, leaving zero-value placeholders for missing indexes. Reject indexes above maxSliceEnvIndex (1000) to avoid huge allocations. Fixes caarlos0#435
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.
Summary
doParseSlicenow sizes slices tomaxIndex+1, preserving gaps with zero-value placeholders (issue expected behavior)maxSliceEnvIndex(1000) returnSliceIndexTooLargeErrorto avoid huge allocations (e.g.FOO_1000000)Fixes #435
Design note
The issue author asked whether gaps should be preserved or compacted. This PR follows the Expected Behavior in the issue (preserve indexes/gaps). Happy to adjust to compacting if maintainers prefer that instead.
Test plan
go test ./...FOO_0/FOO_1/FOO_3gap case