Click here to Skip to main content
15,905,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Reusing an Incremented Variable within a Single Statement [modified] Pin
Joe Woodbury24-Aug-10 7:25
professionalJoe Woodbury24-Aug-10 7:25 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Niklas L24-Aug-10 7:55
Niklas L24-Aug-10 7:55 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums24-Aug-10 7:17
Skippums24-Aug-10 7:17 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Joe Woodbury24-Aug-10 7:38
professionalJoe Woodbury24-Aug-10 7:38 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Paul Michalik24-Aug-10 8:00
Paul Michalik24-Aug-10 8:00 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Joe Woodbury24-Aug-10 8:50
professionalJoe Woodbury24-Aug-10 8:50 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Paul Michalik24-Aug-10 21:28
Paul Michalik24-Aug-10 21:28 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Stefan_Lang24-Aug-10 22:02
Stefan_Lang24-Aug-10 22:02 
If your intent is accessing two arrays within a loop, then - no matter the relation between indices - the fastest way would be to use two pointers to the individual elements and increment these.

If you're so intent on improving performance, consider this: every direct access to an array element via an index value requires
1. loading the start address of the array
2. get the size of an element
3. multiplying that by the index(-1)
4. adding that to the start address
5. dereference this address to get to the actual element.

As opposed to using pointers which just requires
1. load the pointer
2. dereference it

Of course, incrementing the pointers eats up most of this advantage, as you have to add the element size each iteration. And most likely a good optimizer will convert your code into something like this anyway.

What I want to say, using an index is just complicating things unneccesarily if all you want to do is access each element sequentially.
RantRe: Reusing an Incremented Variable within a Single Statement Pin
JFDR_0225-Aug-10 6:37
JFDR_0225-Aug-10 6:37 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums25-Aug-10 7:04
Skippums25-Aug-10 7:04 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Niklas L25-Aug-10 8:02
Niklas L25-Aug-10 8:02 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums25-Aug-10 8:08
Skippums25-Aug-10 8:08 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Niklas L25-Aug-10 8:27
Niklas L25-Aug-10 8:27 
Questiondisplaying the layout of an ogg file Pin
rukita24-Aug-10 4:40
rukita24-Aug-10 4:40 
AnswerRe: displaying the layout of an ogg file Pin
Richard MacCutchan24-Aug-10 5:31
mveRichard MacCutchan24-Aug-10 5:31 
GeneralRe: displaying the layout of an ogg file Pin
rukita24-Aug-10 22:40
rukita24-Aug-10 22:40 
GeneralRe: displaying the layout of an ogg file Pin
Richard MacCutchan25-Aug-10 0:21
mveRichard MacCutchan25-Aug-10 0:21 
QuestionGetting list of user accounts Pin
David Crow24-Aug-10 4:32
David Crow24-Aug-10 4:32 
AnswerRe: Getting list of user accounts Pin
Yusuf24-Aug-10 5:09
Yusuf24-Aug-10 5:09 
QuestionReset dwDesiredAccess, Pin
gothic_coder23-Aug-10 21:47
gothic_coder23-Aug-10 21:47 
AnswerRe: Reset dwDesiredAccess, Pin
Luc Pattyn24-Aug-10 1:09
sitebuilderLuc Pattyn24-Aug-10 1:09 
GeneralRe: Reset dwDesiredAccess, Pin
gothic_coder24-Aug-10 2:17
gothic_coder24-Aug-10 2:17 
GeneralRe: Reset dwDesiredAccess, Pin
gothic_coder24-Aug-10 3:14
gothic_coder24-Aug-10 3:14 
GeneralRe: Reset dwDesiredAccess, Pin
gothic_coder25-Aug-10 22:41
gothic_coder25-Aug-10 22:41 
QuestionMessage Removed Pin
23-Aug-10 20:53
sayonee23-Aug-10 20:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.