From 3fcdb3965eba9353cf64f2ce042475726ad717d7 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 21 May 2017 19:06:05 +0200 Subject: Preallocate --- format.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/format.go b/format.go index 0758da8..4369314 100644 --- a/format.go +++ b/format.go @@ -5,7 +5,8 @@ import ( "strings" ) -func split(s string, n int) (ret []string) { +func split(s string, n int) []string { + ret := make([]string, 0, len(s)/n+1) var pos int if rest := len(s) % n; rest > 0 { ret = append(ret, s[:rest]) -- cgit v1.2.3