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

add ITypeDestructuringPolicy #2034

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

SimonCropp
Copy link
Contributor

IMO it is better to do the type checking once and cache it

@nblumhardt
Copy link
Member

Would be great to bench this.. ConcurrentDictionary used to be horribly slow, but recent versions sound much better, might be a nice win, though I suspect the results will depend heavily on the number of policies.

Assuming the results came out good, what do you think about skipping the new interface and just making this the way we handle IDestructuringPolicy? I.e. a successful TryDestructure(o) would imply CanDestructure(o.Type) and the first successful policy would end up in the dictionary and consulted exclusively on the next occurrence of that type.

I haven't seen too many destructuring policies that are conditional on value rather than type, but I'd guess they exist, or we'd just do this by default... Putting [CacheableByType] or something like that on the policy implementation, as an opt-in marker, would make the contract explicit 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants