Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Consider whether we should implement getHashSumFromBytes #8

Open
rht opened this issue Mar 3, 2022 · 0 comments
Open

Consider whether we should implement getHashSumFromBytes #8

rht opened this issue Mar 3, 2022 · 0 comments

Comments

@rht
Copy link
Collaborator

rht commented Mar 3, 2022

if actual := getHashSum(string(decoded[:])); actual != fileContentHash {
might be a costly copying operation.

According to a comment in https://stackoverflow.com/questions/14373634/how-expensive-is-bytestring

"The book "Programming in Go" made the claim: "The []byte(string) conversion is very fast (O(1)) since under the hood the []byte can simply refer to the string’s underlying bytes with no copying required. The same is true of the reverse conversion, string([]byte); again the underlying bytes are not copied, so the conversion is O(1)." So it seems this claim was incorrect.

But the subsequent comment also links to this open issue golang/go#2205.

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

No branches or pull requests

1 participant