mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-29 09:32:38 +00:00
ce413af0b3
Change size, marshal, and isinit operations on oneofs to look up the currently-set oneof type in a map rather than testing for each possible oneof field in turn. Significantly improves oneof encoding speed for oneofs with a substantial number of fields: go test ./proto -bench=./oneof.*string.*test.TestAll -benchmem -count=8 -cpu=1 name old time/op new time/op delta Encode/oneof_(string)_(*test.TestAllTypes) 911ns ± 1% 397ns ± 3% -56.45% (p=0.000 n=8+7) Decode/oneof_(string)_(*test.TestAllTypes) 899ns ± 1% 922ns ± 1% +2.49% (p=0.001 n=7+7) Fixes golang/protobuf#950 Change-Id: I9393a87975ce09011d885a8af4a63a639ea8452f Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/210281 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>