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
proposal: encoding/binary: 32-bit and 16-bit values #53353
Comments
|
|
@randall77 Thanks for the feedback. I've removed the |
@alzeih That's a fair point for the reading variants. |
We've gotten through over ten years without the lack of these being a problem. If there's a performance issue with AppendVarint(buf, int64(x)) for int32-valued x, maybe we can look at the implementation. But it doesn't seem like we need APIs for smaller ints, which are becoming less and less common. |
This proposal has been added to the active column of the proposals project |
As previously discussed, this proposal is concerned with reading varints, not writing them. What about a func that allows for a caller specified maximum number of bytes to read? This would work for legacy (16, 32-bit), non-standard (24-bit?), and future (128-bit) varint sizes. The existing constants could be provided as an argument. |
What is the actual use case here? Can you just read a varint and then verify that it is in range? |
Reading a uvarint32 from a binary file format and not wanting the func to take more than it should out of the buffer, which would affect reading the rest of the file. |
The varint encoding is self-delimiting. The limit of |
Okay. I was under the impression that reading more of the buffer than intended could be a bad thing (#41185). I can see this proposal is unlikely to proceed based on the feedback. Thanks for the input. |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
encoding/binary
has constants defined for varints of sizes 16, 32, and 64, but no corresponding functions for 16 and 32.go/src/encoding/binary/varint.go
Lines 33 to 37 in 55590f3
I propose the following new functions to be implemented for
src/encoding/binary/varint.go
Uvarint32
Varint32
Uvarint16
Varint16
The text was updated successfully, but these errors were encountered: