|
|
|
|
|
by MichaelGG
4123 days ago
|
|
I think your "executed like" is missing another foreach loop, and the actual function calls (lambdas don't get inlined on the C# compiler, and it's a bit of a crap shoot when counting on the JIT). The end result is the same, but you're eliding a bunch of allocation, branches and method invocations that occur in the actually executed code. Which is the whole point of optimizations for such code, which LINQ lacks. In fact, how else could "Where" be implemented while keeping lazy semantics? (Rust, AFAIK, can actually do this, by inlining everything including the lambdas.) |
|
You're right it's missing the actual function calls, but that wasn't the point: the point here was that LINQ avoids building temporary enumerations and iterating over them like JS functions do.