❔ Questions regarding delegates and closures
If I had some static objects with a delegate member (
My second question would be is it possible to capture a variable without going through the whole closure process? The capturing delegate is also a hot path so I want to avoid instantiating any objects for a function call or at least what could effectively be a function call. There's potentially over 150 different ways of doing things and I don't want to create 150+ types to implement or override a function. I believe anonymous functions are the best way to go about it for the programmer's convenience
I might be overthinking this or have an inadequate understanding of delegates to know if they're right for the task or right for performance. The data is live and constantly being received which is where the concern for performance comes from
Func<byte[], int>) that was assigned an anonymous function on startup, how much slower would calling the delegate be than a regular function after JIT warmup? No closures. This would be a hot path.My second question would be is it possible to capture a variable without going through the whole closure process? The capturing delegate is also a hot path so I want to avoid instantiating any objects for a function call or at least what could effectively be a function call. There's potentially over 150 different ways of doing things and I don't want to create 150+ types to implement or override a function. I believe anonymous functions are the best way to go about it for the programmer's convenience
I might be overthinking this or have an inadequate understanding of delegates to know if they're right for the task or right for performance. The data is live and constantly being received which is where the concern for performance comes from