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 == "" {
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
}