I've got a test job to optimize lambda-expression at runtime. Assuming the lambda contains some "heavy" function calls, what I need is to change the lambda so that all that function calls were cached into temporary variables, which then can substitute the actual function calls in the lambda body.

It must be a function that gets a lambda as a parameter, and returns optimized lambda which you can call then.

I wonder what section of C# is this at all? I mean, like, "learn about reflections" or "learn about generics". What do I need to learn in this case?