From 8f2fa2f0d71835f7c97b1f0661e1065e978ce55f Mon Sep 17 00:00:00 2001 From: rfyiamcool Date: Sun, 25 Feb 2024 10:57:38 +0800 Subject: [PATCH] optimize: pre alloc slice Signed-off-by: rfyiamcool --- slug.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slug.go b/slug.go index 7d9c13a..62e3010 100644 --- a/slug.go +++ b/slug.go @@ -145,7 +145,7 @@ func MakeLang(s string, lang string) (slug string) { // order. Many passes, on one substitution another one could apply. func Substitute(s string, sub map[string]string) (buf string) { buf = s - var keys []string + var keys = make([]string, 0, len(sub)) for k := range sub { keys = append(keys, k) }