Re: C# very optimisation
- From: "James Curran" <jamescurran@xxxxxxxx>
- Date: Wed, 18 May 2005 13:20:55 -0400
"Helge Jensen" <helge.jensen@xxxxxxx> wrote in message
news:#haw$47WFHA.3584@xxxxxxxxxxxxxxxxxxxxxxx
> 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)
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:
The most basic form is
A = B + C;
This would translate into assembler to basically:
ld temp, B ; load B into temp
add temp, C ; add C to temp;
ld A, temp ; Load temp into A
Since the compiler was very stupid with no optimizations, ANY statement
written in that form would be translated the same way.
But, sometimes, you wanted to write:
A = A + C;
This could be translated the same way, but there's a faster way:
add A, C; ; add C to A
But a different translation required a different syntax, hence:
A +=C;
But, sometimes, you wanted to to write:
A = A + 1;
This could be translated the same way, but there's a faster way:
inc A ; increment A
But a different translation required a different syntax, hence:
A++;
--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
.
- 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
- C# very optimisation
- Prev by Date: Reusing a local address/port when creating sockets that send data
- Next by Date: Re: Is this good use of Properties?
- Previous by thread: Re: C# very optimisation
- Next by thread: Re: C# very optimisation
- Index(es):
Relevant Pages
|