Skip to content

Commit 57c1508

Browse files
authored
improve stringutil (#633)
1 parent e0e893c commit 57c1508

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/stringutil/util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package stringutil
33

44
import (
5+
"strings"
56
"unicode/utf8"
67
)
78

@@ -81,7 +82,7 @@ func IsASCIILetter(ch rune) bool {
8182
}
8283

8384
func SplitLines(text string) []string {
84-
var lines []string
85+
lines := make([]string, 0, strings.Count(text, "\n")+1) // preallocate
8586
start := 0
8687
pos := 0
8788
for pos < len(text) {

0 commit comments

Comments
 (0)