Home » Developing U++ » U++ Developers corner » Interesting advantage of using indices instead of iterators
|
Re: Interesting advantage of using indices instead of iterators [message #7616 is a reply to message #7615] |
Wed, 10 January 2007 12:24 |
Balage
Messages: 17 Registered: December 2006
|
Promising Member |
|
|
I've also read a lot about this. It's not just iterators.
Many newcomers (including myself at that time) try to use pointer arithmetic to save that addition on array indexing inside loops. But they all fail to realize, that the compiler can do way much better optimizations if it knows what is just read from memory, and what is updated (and also when). Pointer arithmetic makes it a lot harder to figure that out, as the compiler cannot easily track where a pointer currently points to.
With regular array indexing, it exactly knows what element, when, and how is being accessed, and that's very good for optimization.
[Updated on: Wed, 10 January 2007 12:30] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri May 10 05:07:25 CEST 2024
Total time taken to generate the page: 0.02360 seconds
|