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

optimization suggestions #18

Open
kofifus opened this issue Mar 20, 2020 · 0 comments
Open

optimization suggestions #18

kofifus opened this issue Mar 20, 2020 · 0 comments

Comments

@kofifus
Copy link

kofifus commented Mar 20, 2020

Two ideas for optimization:

  1. There is no need to add-to / find-in the InstanceExpressionCache cache (that is call ResolveInstance) when mutating a non nested member because we already have the instance in source in that case

  2. Instead of creating & compiling an activator and a separate array of parameter resolvers (ActivationContext), create and cache a single lambda with an expression block:

(object instance, object val) => new TheType((MemberType)val, ((TheType)instance).LastName)

ie

(object x, object v) => new Employee((String)v, ((Employee)x).LastName)

This means you don't need to loop over the members if you had a cache hit, this also makes it easy to add a desirable feature where you can mutate multiple members with a single ctor call

Hope this helps
(you can see these ideas in practice here)

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

No branches or pull requests

1 participant