Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/impl: improve MessageInfo.New performance
Calling the ProtoReflect method of the newly-constructed message avoids an allocation in MessageInfo.MessageOf in the common case of a generated message with an optimized ProtoReflect method. Benchmark for creating an empty message, darwin/arm64 M1 laptop: name old time/op new time/op delta EmptyMessage/New-10 32.1ns ± 2% 23.7ns ± 2% -26.06% (p=0.000 n=10+9) name old alloc/op new alloc/op delta EmptyMessage/New-10 64.0B ± 0% 48.0B ± 0% -25.00% (p=0.000 n=10+10) name old allocs/op new allocs/op delta EmptyMessage/New-10 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=10+10) Change-Id: Ifa3c3ffa8edc76f78399306d0f4964eae4aacd28 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/418677 Reviewed-by: Michael Stapelberg <stapelberg@google.com> Reviewed-by: Lasse Folger <lassefolger@google.com>
- Loading branch information