Skip to content
Myr

Fix nthTransformer parts slice preallocation (#4734)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by cui · committed by GitHub · parent 2202481 · Browse files · 1 file+1 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:src/options.go+1 added-1 removed
867 unmodified lines
868 index bool869 nth []Range870 }871872 parts := make([]NthParts, len(indexes))872 parts := make([]NthParts, 0, len(indexes))873 idx := 0874 for _, index := range indexes {875 if idx < index[0] {876 parts = append(parts, NthParts{str: str[idx:index[0]]})
3053 unmodified lines