fastcache
fastcache copied to clipboard
https://github.com/VictoriaMetrics/fastcache/blob/master/fastcache.go#L392
why doesnt use bytes.Equal() ? so we dont need additional string() comparison
if string(k) == string(chunk[idx:idx+keyLen]) {
Because bytes.Equal is implemented in the same way - see https://cs.opensource.google/go/go/+/refs/tags/go1.17:src/bytes/bytes.go;l=18 :
func Equal(a, b []byte) bool {
return string(a) == string(b)
}
Go compiler automatically optimizes such a comparison in the most efficient way.