Skip to content

Commit

Permalink
proto: add reference to size semantics with lazy decoding to comment
Browse files Browse the repository at this point in the history
For golang/protobuf#1657

Change-Id: I01007ed586d1833517735cf5f38cca302efb9801
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635137
Reviewed-by: Cassondra Foesch <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
  • Loading branch information
stapelberg committed Dec 16, 2024
1 parent 560503e commit 5376513
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions proto/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5376513

Please sign in to comment.