-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
-
None
The existing codepath for marshalling a bson.D requires looking up registry entries for each element. We can optimize away these registry lookups by adding an opt-in encoder that treats bson.D as a closed type system and only marshals a small set of types (e.g. basic scalar types + the ones in the primitive package) and errors for others (e.g. if one of the document values is a struct). This encoder should live in x/bsonx and should not be registered by default.