You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The converters are many. And because we know that they are locked on the type and does not do any fancy calculations inside the CanConvert method, we might as well toss them into a Dictionary<Type, JsonConverter> instead of having Newtonsoft.Json loop through every single one for every serialization.
It will have to do the lookup twice for every conversion. But two dictionary lookups is probably faster than a single loop-through-every-item. Needs to be benchmarked!
Motivation
Would make serialization/deserialization faster
Suggested solution
Create a JsonConverter that in its CanConvert does a .ContainsKey on the dictionary of converters, and inside the ReadJson and WriteJson it just forwards the calls to the appropriate converter.
The text was updated successfully, but these errors were encountered:
Description
The converters are many. And because we know that they are locked on the type and does not do any fancy calculations inside the CanConvert method, we might as well toss them into a
Dictionary<Type, JsonConverter>
instead of having Newtonsoft.Json loop through every single one for every serialization.It will have to do the lookup twice for every conversion. But two dictionary lookups is probably faster than a single loop-through-every-item. Needs to be benchmarked!
Motivation
Would make serialization/deserialization faster
Suggested solution
Create a JsonConverter that in its CanConvert does a
.ContainsKey
on the dictionary of converters, and inside the ReadJson and WriteJson it just forwards the calls to the appropriate converter.The text was updated successfully, but these errors were encountered: