|
|
|
|
|||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Which is faster?
lak wrote:
Which is faster? Post Increment or assignment? Why? I was not able to get any things. /Usually/ -- I very carefully am not saying /always/ -- the timing difference between using an auto-increment/decrement, pre or post, vs an assignment like `spoo += 1`, is not detectable in a run of an application. This is because compilers are pretty smart and (although they may need a little encouragement) will compile the various different ways of saying "increment spoo" into the same code, if that's legal. And I/ isn't cheap. And the Standard doesn't say /anything/ about what the relative costs are. So, if it matters -- I say, /if/ it matters -- the faster thing to use, if there is one, has to be determined by experiment, and you have to realise that which the faster one is can change as soon as you change machines, compilers, compiler options, memory size, air conditioning, or the colour of your tie. , which is to say, usually, pick whichever most clearly expresses your intent to your audience. -- 'It changed the future and it changed us.' /Babylon 5/ Hewlett-Packard Limited registered office: Cain Road, Bracknell, registered no: 690597 England Berks RG12 1HN |
![]() |
| Viewing: Web Development Archives > FAQs > C/C++ > Which is faster? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|