Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://github.com/VictoriaMetrics/fastcache/blob/master/fastcache.go#L392 #59

Open
superdolt opened this issue Aug 28, 2021 · 1 comment
Labels
question Further information is requested

Comments

@superdolt
Copy link

superdolt commented Aug 28, 2021

why doesnt use bytes.Equal() ? so we dont need additional string() comparison

if string(k) == string(chunk[idx:idx+keyLen]) {

@valyala valyala added the question Further information is requested label Aug 29, 2021
@valyala
Copy link
Collaborator

valyala commented Aug 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants