Repository navigation
internal: use seq iterators to avoid allocations - #2354
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Replace slice-based string iteration internal/providers/cmdline/cmdline.go, internal/exec/stages/disks/luks.go, internal/exec/stages/disks/partitions.go, internal/providers/zvm/zvm.go, tests/positive/general/preemption.go, internal/providers/vmware/ovf_test.go, docs/release-notes.d/string-iterators.change.md |
Loops use strings.FieldsSeq or strings.SplitSeq instead of iterating over slices created by strings.Fields or strings.Split. The release note describes the iterator change. |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Refactor
Possibly related issues
- Issue 2353 describes the release-note fragment workflow used by this change.
Possibly related PRs
- coreos/ignition#2352: Adds validation and finalization tooling for release-note fragments used here.
- coreos/ignition#2347: Introduces the release-note fragment format used here.
- coreos/ignition#2346: Re-enables the
go fixpipeline whose reported string-iterator changes are applied here.
Suggested reviewers: bgilbert
Merge Risk: 
Minimal · up to 14891
-
This allocation-focused change is ready to merge; no material current-head risk was identified.
Pre-merge checks: 
5 · 
1
-
Failed checks: 1 warning Passed checks: 5 passed-
Full details: Commit Message Convention
-
Explanation
The PR has one non-merge commit:
internal: use string iterators to avoid allocations.internalis a valid subsystem path prefix,usestarts the description in lowercase imperative mood, and the message has no trailing period.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 6 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Binary size report (
|
| Size | |
|---|---|
Base (main) |
33MiB |
| PR (#2354) | 33MiB |
| Delta | +5.6KiB (0.02%) |
angelcerveraroldan
left a comment
There was a problem hiding this comment.
I did not know that these methods existed, neat.
From the docs:
The iterator yields the same strings that would be returned by Fields(s), but without constructing the slice.
The iterator yields the same strings that would be returned by Split(s, sep), but without constructing the slice. It returns a single-use iterator
So it LGTM, thanks.
Updates the strings.Split and strings.Field calls to use the SplitSeq and FieldSeq iterators respectively to save an allocation as recommended by the
go fixpipeline.Each line changed here can be found in the most recent
go fixsection of thetestci in main here:https://github.com/coreos/ignition/actions/runs/40920068661/job/123610575785#step:7:3039
https://github.com/coreos/ignition/actions/runs/40920068661/job/123610575785#step:7:3071
https://github.com/coreos/ignition/actions/runs/40920068661/job/123610575785#step:7:3158
https://github.com/coreos/ignition/actions/runs/40920068661/job/123610575785#step:7:3169
https://github.com/coreos/ignition/actions/runs/40920068661/job/123610575785#step:7:3204
https://github.com/coreos/ignition/actions/runs/40920068661/job/123610575785#step:7:3182