SecretSoftware wrote:14) the compiler should be a smart compiler. Basically when you have repetitive code that is similar in manipulation of things, but is different in minor areas, that it groups the similar stuff together into new methods, and arrange for the flow to be correct at the same time. This would result in small size product and efficent code.
The MSIL code you see when looking at it with ILDASM is the real code that gets executed... The runtime is inlining and removing vtables etc. (the jitter and managed runtime is also here for something). That happens all behind the scenes. The runtime does already a lot to make code faster and remove duplicate stuff.
I wouldn't like the compiler to remove a piece of code an call another method that does the same, just because he thinks so. That's weird if you do performance checking etc. It looks non deterministic to the user. The developer might also have thought a little bit when putting the code not in the other method, when having it in two methods... Performance, for example, could be a reason.
It's better to educate the developers to write better code then having the compiler to do it!