Skip to content

Commit 8f2fa2f

Browse files
rfyiamcoolmatrixik
authored andcommitted
optimize: pre alloc slice
Signed-off-by: rfyiamcool <[email protected]>
1 parent 412e31a commit 8f2fa2f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

slug.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func MakeLang(s string, lang string) (slug string) {
145145
// order. Many passes, on one substitution another one could apply.
146146
func Substitute(s string, sub map[string]string) (buf string) {
147147
buf = s
148-
var keys []string
148+
var keys = make([]string, 0, len(sub))
149149
for k := range sub {
150150
keys = append(keys, k)
151151
}

0 commit comments

Comments
 (0)