|
I ended up implementing this optimization in a slightly different way: the driver keeps track of which classes have discriminators registered for them. That way it can figure out automatically whether it is safe to skip looking for a discriminator or not based on the nominalType of the class being deserialized (because if no subclass of nominalType has a discriminator registered there's no need to look for one).
|
|
then there should either
1. have a configurable way to do so via BsonClassMap
2. add additional custom attribute to configure this
3. add convention setting to say that for my object models, I don't have discriminator
|
|
I agree. We need to be careful about knowing when it is safe to skip looking for a discriminator. DiscriminatorIsRequired false doesn't necessarily mean there is no discriminator. My thinking is that we can skip looking for a discriminator when the nominalType has no subclasses (sealed guarantees that, but even non-sealed classes often don't have subclasses). This is on my TODO list.
|
|
this can help read performance significantly as it doesn't need to go through elements twice for most of the classes without discriminator
|
Generated at Wed Feb 07 21:35:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.