Hi Andrei, This doesn't work for proto3 where we need to support "open enums" so that enum values added to an enum definition but not yet compiled into the receiver can still be stored and accessed as a raw int. This can't be done with Java's Enums which are "closed enums". Our long term plan is that proto enums will default to open as in proto3, so we are unlikely to change this behavior. If enum access is unacceptably slow, consider switching to int32 values -- it is a wire compatible change though certainly not quite as convenient or self-documenting.
-Jerry On Sunday, January 15, 2023 at 5:56:07 PM UTC-7 Andrei Solodin wrote: > Greetings , in our Java application we use the protobuf object model quite > a bit. While profiling, I have noticed that simply getting an enum value > from an object is quite slow. It appears to be caused by the fact that the > object stores internally an int which must be converted to a java enum on > ever call to the getter. If the object just stored the enum value directly, > this would not be necessary. The required translation between int<->enum > could just be done once on (de)serialization. Wondering if this would > qualify for a performance request.[image: GetImageAttachment.png] > > Thanks > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/283db149-4c47-4f2a-9377-3effdec49d12n%40googlegroups.com.
