Fix nthTransformer parts slice preallocation (#4734)
Some checks failed
CodeQL / Analyze (go) (push) Has been cancelled
build / build (push) Has been cancelled
Test fzf on macOS / build (push) Has been cancelled

Use make([]NthParts, 0, len(indexes)) so the slice starts empty with
reserved capacity. The previous length-len(indexes) allocation left
leading zero NthParts entries before appended elements.
This commit is contained in:
cui
2026-03-23 08:55:00 +08:00
committed by GitHub
parent 2202481705
commit 14e3995a06

View File

@@ -869,7 +869,7 @@ func nthTransformer(str string) (func(Delimiter) func([]Token, int32) string, er
nth []Range
}
parts := make([]NthParts, len(indexes))
parts := make([]NthParts, 0, len(indexes))
idx := 0
for _, index := range indexes {
if idx < index[0] {