Ben Voigt said:
Which occasionally is a performance-killing mistake.
For example, a type initializer. Is there ever an advantage to optimizing
the .cctor? Anything I can think of that could need optimization (anonymous
methods, expression trees, etc) has already been separated by the compiler
before any MSIL is generated.
Likewise the initialization code for most forms is often executed only
once. I believe that Sun's HotSpot JIT will interpret code the first
time it runs, unless it spots significant loops. The benefit of the
"always JIT, and JIT exactly once" solution is that it's much simpler
than the kind of optimisation HotSpot performs. But yes, there can be a
price to pay.