cache converted name (#3736)

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
This commit is contained in:
alresvor 2020-11-16 15:16:15 +08:00 committed by GitHub
parent a9f54d53fb
commit a4c0c6b400
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -95,7 +95,7 @@ func toDBName(name string) string {
if name == "" { if name == "" {
return "" return ""
} else if v, ok := smap.Load(name); ok { } else if v, ok := smap.Load(name); ok {
return fmt.Sprint(v) return v.(string)
} }
var ( var (
@ -134,6 +134,7 @@ func toDBName(name string) string {
} else { } else {
buf.WriteByte(value[len(value)-1]) buf.WriteByte(value[len(value)-1])
} }
ret := buf.String()
return buf.String() smap.Store(name, ret)
return ret
} }