From 5376513e4bee83f79be3f40c47e203f3f071ce8e Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 13 Dec 2024 15:03:11 +0100 Subject: [PATCH] proto: add reference to size semantics with lazy decoding to comment For golang/protobuf#1657 Change-Id: I01007ed586d1833517735cf5f38cca302efb9801 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635137 Reviewed-by: Cassondra Foesch LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil --- proto/size.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proto/size.go b/proto/size.go index 052fb5ae..c8675806 100644 --- a/proto/size.go +++ b/proto/size.go @@ -12,11 +12,19 @@ import ( ) // Size returns the size in bytes of the wire-format encoding of m. +// +// Note that Size might return more bytes than Marshal will write in the case of +// lazily decoded messages that arrive in non-minimal wire format: see +// https://protobuf.dev/reference/go/size/ for more details. func Size(m Message) int { return MarshalOptions{}.Size(m) } // Size returns the size in bytes of the wire-format encoding of m. +// +// Note that Size might return more bytes than Marshal will write in the case of +// lazily decoded messages that arrive in non-minimal wire format: see +// https://protobuf.dev/reference/go/size/ for more details. func (o MarshalOptions) Size(m Message) int { // Treat a nil message interface as an empty message; nothing to output. if m == nil {