Comment

Comment by mumblemumble

Just taking a stab at it; this might not be exactly right --

It's kind of down to C# being compiled into bytecode and then JIT compiled at run-time. During the initial compilation phase, the compiler doesn't necessarily have enough information to know whether `ElementAt()` or `Name` has side effects. (I assume here that Name is a property getter and not a field, in keeping with .NET conventions.) And then at run time the JIT compiler isn't as aggressive as an AOT compiler would typically be about optimization, so it may be less likely to do any dead store elimination.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton