Repository navigation
docs: clarify UnmarshalMsg input and receiver storage - #458
Closed
ViktorBystrov72 wants to merge 1 commit into
Closed
ViktorBystrov72 wants to merge 1 commit into
ViktorBystrov72 wants to merge 1 commit into
Conversation
Signed-off-by: Виктор Быстров <anatema@bk.ru>
klauspost
reviewed
Nov 13, 2026
klauspost
left a comment
Collaborator
There was a problem hiding this comment.
Seems like extra fluff with no value.
Comment on lines
+99
to
+101
| // Generated methods read encoded data from the input slice's length. They do not | ||
| // use spare capacity in that slice as scratch space; an input slice with equal | ||
| // length and capacity is sufficient. |
Collaborator
There was a problem hiding this comment.
This seems to expand the requirements of the interface. While it may hold (and surely is good practice) the details are left to the implementer.
I honestly don't see a need to specify this.
Comment on lines
+103
to
+107
| // Generated methods can reuse storage in the receiver, such as existing slice | ||
| // capacity and maps. Reusing the receiver across calls can therefore reduce | ||
| // allocations. Extra capacity in the input slice does not provide this benefit. | ||
| // Decoding can still allocate, for example when growing receiver slices or | ||
| // reading strings with [ReadStringBytes]. |
Collaborator
There was a problem hiding this comment.
This also seems unnecesary.
Author
|
Thanks for the review. The wording overstates the interface contract, and removing the rejected paragraphs leaves no useful change. Withdrawing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clarify the distinction between the encoded input buffer and reusable storage in generated
UnmarshalMsgreceivers. Input with equal length and capacity is sufficient; adding spare input capacity does not prevent allocations in decoded fields. Document the returned suffix for concatenated objects and the limits of receiver reuse, including string and slice-growth allocations.This expands the public interface GoDoc in response to #154. It does not change decoding behavior or the separately maintained wiki.
Validation:
make prepare, package race tests and vet passed. A separate probe using freshly generated methods decoded concatenated objects withlen(input) == cap(input)and verified that a preallocated receiver retained its slice backing arrays across calls. The rendered GoDoc was checked withgo doc.Refs #154.