Shopify / protoboeuf

Experimenting with a protobuf implementation
MIT License
24 stars 2 forks source link

Store enum state on `Field` instances, rather than in the parser #61

Closed paracycle closed 3 months ago

paracycle commented 3 months ago

Currently, the parser needs to check if a field type is an enum or not, for every field. This is a bit inefficient, and it is quite non-ergonomic.

Instead, if we store the enum state of a field on the Field instance, we can just check that directly, which is what this commit does.

When we initialize a MessageCompiler instance, we know all of the enum types, so we can use that information to set the enum state on the fields are of those types.