File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,11 @@ package proto
2323import (
2424 "fmt"
2525
26- "google.golang.org/grpc/encoding"
27- "google.golang.org/grpc/mem"
2826 "google.golang.org/protobuf/proto"
2927 "google.golang.org/protobuf/protoadapt"
28+
29+ "google.golang.org/grpc/encoding"
30+ "google.golang.org/grpc/mem"
3031)
3132
3233// Name is the name registered for the proto compressor.
@@ -48,15 +49,15 @@ func (c *codecV2) Marshal(v any) (data mem.BufferSlice, err error) {
4849
4950 size := proto .Size (vv )
5051 if mem .IsBelowBufferPoolingThreshold (size ) {
51- buf , err := proto .Marshal (vv )
52+ buf , err := proto.MarshalOptions { UseCachedSize : true }. Marshal (vv )
5253 if err != nil {
5354 return nil , err
5455 }
5556 data = append (data , mem .SliceBuffer (buf ))
5657 } else {
5758 pool := mem .DefaultBufferPool ()
5859 buf := pool .Get (size )
59- if _ , err := (proto.MarshalOptions {}).MarshalAppend ((* buf )[:0 ], vv ); err != nil {
60+ if _ , err := (proto.MarshalOptions {UseCachedSize : true }).MarshalAppend ((* buf )[:0 ], vv ); err != nil {
6061 pool .Put (buf )
6162 return nil , err
6263 }
You can’t perform that action at this time.
0 commit comments