You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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 caseInstead of creating & compiling an activator and a separate array of parameter resolvers (
ActivationContext
), create and cache a single lambda with an expression block:ie
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)
The text was updated successfully, but these errors were encountered: