Re: C# very optimisation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



James Curran wrote:

but since the dawn of time C-programmers have preferred the (1 character
shorter) "i++" to "i+=1". There have *never* *ever* been *any*
performance-reason for this.


    No, actually there was.  Remember that the original C compiler was
written for a very small machine -- one which measured memory in KB, not MB
(and probably measure it with only 2 digits or fewer)

Can you point to a C-compiler, even a *really* old one, that does not optimize "x = x + 1" to some available ASM instruction (if one exists on that architecture) that increments x?


    Nothing about it the language is superflious.  If the syntax was
different, the code produced would be different.  The best way to see this
is to consider what you can't do with a particular syntax:
Since the compiler was very stupid with no optimizations,  ANY statement
written in that form would be translated the same way.

I have never seen any compiler do that. Do you have an example?

[...more examples cutted...]

I have implemented compilers, i know how code generation works. If a compiler have *any* optimizations at all I would hazard a guess that "x = x + c" is optimized.

--
Helge Jensen
  mailto:helge.jensen@xxxxxxx
  sip:helge.jensen@xxxxxxx
               -=> Sebastian cover-music: http://ungdomshus.nu <=-
.


Quantcast