-
Notifications
You must be signed in to change notification settings - Fork 23
Cache reflection operations #25
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
Conversation
JSONAPI/Core/ModelManager.cs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this return IDictionary instead of Dictionary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, probably. I'll change that.
… IsMany and GetSingleType.
…e one of the use cases. Added tests.
…y with JsonApiFormatter, and the interface boundary is much more clear.
…ttribute and elsewhere!
|
Okay, I'm done with the big refactoring pass. @csantero please have a look. Notes:
|
JSONAPI/Core/IModelManager.cs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say "Inverse of GetJsonKeyForProperty"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, thanks
|
@SphtKr This is really good. I'm excited about the peformance improvements this will offer (although we don't have any performance tests to prove this). I've submitted a PR to clean up those constructors a bit. Does ModelManager need to have a parameterless constructor at all? Can we just remove that and also the equivalent parameterless constructor on JsonApiFormatter? Then the user can't not provide a pluralization service. |
rearrange constructors
|
I suppose not, it's left over from the singleton pattern in the case of ModelManager I suppose. And yes now there's no reason to have the parameter-less constructor on JsonApiFormatter either. That's good too, because I don't want it to be easy for the user to use the default pluralizer, since it's so naïve, they should have to choose it. |
…onstructors. Added caching to `IsSerializedAsMany` and `GetElementType`. Made `ModelManager` a little more subclassing-friendly.
Caches several reflection code paths that tended to get executed often with the same types, so should have a very positive effect on performance. Closes #23.