News for hackers. Stuff that matters.
Re:Classes vs. Structs in .NET. How not to teach about perfo... by kevingadd on Sunday November 05, 2023 @08:28AM (#38150945)
It's impossible to guarantee that count and elementat have no side effects unless you fully devirtualize everything, which can't be done at compile time since the application's dependencies (SDK/runtime, third party libraries) could be swapped out before it runs.

So these optimizations would have to occur in the JIT and might come at the cost of worse startup time or memory usage.

Fwiw modern .net is getting pretty good at devirt but I don't expect it would optimize all this out.

There are no comments on this comment yet.