Removing Linq Usage #45060
-
I’ve noticed a number of commits that are refactoring code to remove Linq usage. Why is Linq usage being removed? Is there something inherently bad about linq? I feel like the Linq code is easier to understand and reason about as opposed to nested loops. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
LINQ to Objects is great for productivity and succinctly expressing intent. It's not great for high performance, incurring overheads like allocations for delegates and closures, delegate invocations per element, multiple interface dispatch per element, type checks, decreased opportunity for JIT optimization, etc. For code where performance is paramount, such as in dotnet/runtime, it's better to avoid most of LINQ. |
Beta Was this translation helpful? Give feedback.
LINQ to Objects is great for productivity and succinctly expressing intent. It's not great for high performance, incurring overheads like allocations for delegates and closures, delegate invocations per element, multiple interface dispatch per element, type checks, decreased opportunity for JIT optimization, etc. For code where performance is paramount, such as in dotnet/runtime, it's better to avoid most of LINQ.