100-go-mistakes/12-optimizations/96-reduce-allocations/compiler/main.go
2021-12-27 15:56:17 +01:00

16 lines
276 B
Go

package main
type cache struct {
m map[string]int
}
func (c *cache) get1(bytes []byte) (v int, contains bool) {
key := string(bytes)
v, contains = c.m[key]
return
}
func (c *cache) get2(bytes []byte) (v int, contains bool) {
v, contains = c.m[string(bytes)]
return
}