Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect converters into one via Dictionary #13

Open
applejag opened this issue Apr 25, 2020 · 1 comment
Open

Collect converters into one via Dictionary #13

applejag opened this issue Apr 25, 2020 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@applejag
Copy link
Owner

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.

@applejag applejag added the enhancement New feature or request label Apr 25, 2020
@applejag applejag changed the title Suggestion: Collect converters into one via Dictionary Collect converters into one via Dictionary Apr 25, 2020
@applejag applejag added this to the x.2.0 milestone Apr 25, 2020
@applejag
Copy link
Owner Author

applejag commented Apr 5, 2021

This is potentionally a breaking change. Moving this to 2.0.0 milestone

@applejag applejag modified the milestones: 1.1, 2.0 Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant