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

Use caching for Delegates #162

Closed
jerviscui opened this issue Jul 25, 2021 · 2 comments
Closed

Use caching for Delegates #162

jerviscui opened this issue Jul 25, 2021 · 2 comments
Milestone

Comments

@jerviscui
Copy link
Contributor

jerviscui commented Jul 25, 2021

If Aspect around the method, it will generate code like:

private object __a$_around_Method_100663472_w_0(object[] A_1)
{
    return this.Aspect.Around(new Func<object[], object>(this.__a$_around_Method_100663472_u), A_1);
}

The new Func<>() method will be exectued each time for create Delegate.
How about use a static field cache Delegate,

static Func<@classType, object[], object> Func = this.__a$_around_Method_100663472_u;

private object __a$_around_Method_100663472_w_0(object[] A_1)
{
    return this.Aspect.Around(Func, this, A_1);
}

private static object __a$_around_Method_100663472_u(@classType instance, object[] A_1)
{
    return instance.__a$_around_Method_100663472_o((int)A_1[0]);
}

Do you think it's worth it?

@pamidur
Copy link
Owner

pamidur commented Aug 6, 2021

I like your idea! It looks doable, and will speed up execution especially on Around-heavy workloads.
for instance methods we will need instance properties
for static methods we will need static properies

@pamidur pamidur changed the title Using caching for Delegate? Use caching for Delegates Aug 6, 2021
@pamidur pamidur added this to the 2.x milestone Aug 6, 2021
@pamidur
Copy link
Owner

pamidur commented Oct 18, 2021

moved to #137

@pamidur pamidur closed this as completed Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants