-
Notifications
You must be signed in to change notification settings - Fork 18k
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
hash: should use binary.BigEndian's AppendUint{32|64} and Uint{32|64} instead of handwritten helper functions #63719
Comments
Taking out of the proposal process because there's no new API here. |
Thanks. I will send a PR later. |
There are some import cycles between hash and encoding/binary. So only we can do is to keep the helper functions as same as that in the binary package and let other code keep them it as. |
Can not use encoding/binary in hash packages because of import cycles. So just keep the appendUint and readUint helper functions same as that in the encoding/binary standard package. Updates golang#63719
Change https://go.dev/cl/537796 mentions this issue: |
Can not use encoding/binary in hash packages because of import cycles. So just keep the appendUint and readUint helper functions same as that in the encoding/binary standard package. Updates golang#63719
We can not use encoding/binary in hash packages because of import cycles. So just keep the appendUint and readUint helper functions same as that in the encoding/binary standard package. There is no notable performance impacts. Updates #63719 Change-Id: If47a7faaf9d422d772f32bbe1fa2f2c8a16485f4 GitHub-Last-Rev: f334fee GitHub-Pull-Request: #63746 Reviewed-on: https://go-review.googlesource.com/c/go/+/537796 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
CL#66710 implements the BinaryMarshaler and BinaryUnmarshaler interfaces, which introduce handwritten helper functions like appendUint32/appendUint64/readUint32/readUint64.
For example, look at hash/crc64/crc64.go:
There are many of the same helper functions in other packages.
Since CL#386017, these functions become the public interface to the binary standard library.
Code using these helper functions can be easily rewritten, using crc64 as an example:
Before:
After:
There are these reasons below to support this refactoring:
Packages that need to be refactored:
The text was updated successfully, but these errors were encountered: