35 ms·
> modern .NET does all kinds of insane runtime optimization techniques to make sure things go fast Not as much of this applies to LINQ as we'd all wish. If you
by electroly 3y ago
> modern .NET does all kinds of insane runtime optimization techniques to make sure things go fast
Not as much of this applies to LINQ as we'd all wish. If you've got LINQ in a performance hotspot, the first thing to do is remove the LINQ. I love LINQ but plainly written loops are faster every time, and removing LINQ from profiled hotspots has always been a successful optimization for me in practice. Avoid it in performance hotspots. Once you've removed the LINQ, eliminate any inner-loop heap allocations and you're probably done optimizing. LINQ and heap allocation are the two major killers of performance in typical C# code.