Re: C# very optimisation
- From: Helge Jensen <helge.jensen@xxxxxxx>
- Date: Wed, 18 May 2005 19:40:51 +0200
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 <=- .
- Follow-Ups:
- Re: C# very optimisation
- From: Helge Jensen
- Re: C# very optimisation
- References:
- C# very optimisation
- From: Ennixo
- Re: C# very optimisation
- From: Jon Skeet [C# MVP]
- Re: C# very optimisation
- From: Ennixo
- Re: C# very optimisation
- From: Lebesgue
- Re: C# very optimisation
- From: Ennixo
- Re: C# very optimisation
- From: Søren Reinke
- Re: C# very optimisation
- From: Helge Jensen
- Re: C# very optimisation
- From: Frank Hileman
- Re: C# very optimisation
- From: Helge Jensen
- Re: C# very optimisation
- From: James Curran
- C# very optimisation
- Prev by Date: Re: How to specify default text for a custom button control.
- Next by Date: Re: Lacking for-loop optimization in C#
- Previous by thread: Re: C# very optimisation
- Next by thread: Re: C# very optimisation
- Index(es):