Skip to content

optimization suggestions #18

@kofifus

Description

@kofifus

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions