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

Why copy string to [64]byte slice instead of converting it ? #20

Open
azr opened this issue Sep 12, 2017 · 1 comment
Open

Why copy string to [64]byte slice instead of converting it ? #20

azr opened this issue Sep 12, 2017 · 1 comment

Comments

@azr
Copy link

azr commented Sep 12, 2017

consistent/consistent.go

Lines 238 to 245 in 75142be

func (c *Consistent) hashKey(key string) uint32 {
if len(key) < 64 {
var scratch [64]byte
copy(scratch[:], key)
return crc32.ChecksumIEEE(scratch[:len(key)])
}
return crc32.ChecksumIEEE([]byte(key))
}

for performances reasons ?

( hi ! )

@azr azr changed the title Why copy string to empty byte slice instead of typecasting it ? Why copy string to [64]byte slice instead of converting it ? Sep 12, 2017
@alisanguo
Copy link

I have the same question, Did you get it?

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

No branches or pull requests

2 participants