-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Two ideas for optimization:
-
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 -
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)
Metadata
Metadata
Assignees
Labels
No labels