From 14e3995a06e6a92a48d982c45f48595be1199002 Mon Sep 17 00:00:00 2001 From: cui Date: Mon, 23 Mar 2026 08:55:00 +0800 Subject: [PATCH] Fix nthTransformer parts slice preallocation (#4734) 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. --- src/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options.go b/src/options.go index 36fd0d18..479d3416 100644 --- a/src/options.go +++ b/src/options.go @@ -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] {