From a4c0c6b400586283cfd2ec74d1bb8c5c0a5dd4fb Mon Sep 17 00:00:00 2001 From: alresvor Date: Mon, 16 Nov 2020 15:16:15 +0800 Subject: [PATCH] cache converted name (#3736) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BenchmarkToName-8 2322307 521 ns/op 88 B/op 5 allocs/op ↓ BenchmarkToName-8 19997366 55.0 ns/op 0 B/op 0 allocs/op --- schema/naming.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/schema/naming.go b/schema/naming.go index dbc71e04..e3b2104a 100644 --- a/schema/naming.go +++ b/schema/naming.go @@ -95,7 +95,7 @@ func toDBName(name string) string { if name == "" { return "" } else if v, ok := smap.Load(name); ok { - return fmt.Sprint(v) + return v.(string) } var ( @@ -134,6 +134,7 @@ func toDBName(name string) string { } else { buf.WriteByte(value[len(value)-1]) } - - return buf.String() + ret := buf.String() + smap.Store(name, ret) + return ret }