Click here to Skip to main content
15,912,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSplitter window question Pin
Chakrdeep9-May-04 3:15
Chakrdeep9-May-04 3:15 
GeneralRe: Splitter window question Pin
Ravi Bhavnani9-May-04 4:22
professionalRavi Bhavnani9-May-04 4:22 
GeneralIP lister... Pin
Snyp9-May-04 3:03
Snyp9-May-04 3:03 
GeneralRe: IP lister... Pin
Andrew Walker9-May-04 3:25
Andrew Walker9-May-04 3:25 
GeneralRe: IP lister... Pin
Ravi Bhavnani9-May-04 4:25
professionalRavi Bhavnani9-May-04 4:25 
GeneralRe: IP lister... Pin
Snyp9-May-04 4:28
Snyp9-May-04 4:28 
GeneralRe: IP lister... Pin
Paul Ranson10-May-04 1:13
Paul Ranson10-May-04 1:13 
GeneralRe: IP lister... Pin
David Crow10-May-04 3:23
David Crow10-May-04 3:23 
GeneralRe: IP lister... Pin
David Crow10-May-04 3:18
David Crow10-May-04 3:18 
GeneralMemory allocation Pin
Luis Ricardo9-May-04 2:06
Luis Ricardo9-May-04 2:06 
GeneralConvert to UCS-2 .. Pin
rasha20038-May-04 23:11
rasha20038-May-04 23:11 
GeneralRe: Convert to UCS-2 .. Pin
Michael Dunn9-May-04 5:51
sitebuilderMichael Dunn9-May-04 5:51 
GeneralRe: Convert to UCS-2 .. Pin
rasha20039-May-04 8:20
rasha20039-May-04 8:20 
GeneralRe: Convert to UCS-2 .. Pin
Michael Dunn9-May-04 20:11
sitebuilderMichael Dunn9-May-04 20:11 
GeneralRe: Convert to UCS-2 .. Pin
rasha200310-May-04 5:09
rasha200310-May-04 5:09 
Generalabout allocator Pin
vividtang8-May-04 21:16
vividtang8-May-04 21:16 
GeneralRe: about allocator Pin
toxcct9-May-04 5:54
toxcct9-May-04 5:54 
GeneralNewbie string question Pin
MikeUofPhx8-May-04 17:00
MikeUofPhx8-May-04 17:00 
GeneralRe: Newbie string question Pin
Anonymous8-May-04 20:27
Anonymous8-May-04 20:27 
GeneralRe: Newbie string question Pin
John R. Shaw8-May-04 22:13
John R. Shaw8-May-04 22:13 
GeneralRe: Newbie string question Pin
MikeUofPhx9-May-04 13:41
MikeUofPhx9-May-04 13:41 
GeneralOLE DB 'IColumnsInfo2' problem Pin
KalliMan8-May-04 13:06
KalliMan8-May-04 13:06 
QuestionWhich of these methods is more efficient? Pin
Joe Smith IX8-May-04 12:48
Joe Smith IX8-May-04 12:48 
Hi all,

This might be a simple question, and you might say that both ways have their own pros and cons (and the pros and cons are so minor, that they are negligible, therefore they are virtually equally efficient). But sometimes I wonder if every single bit of memory and every cpu cycle count, which one is better?

Thanks for any input.

<br />
// myArray is an array of CMyObject<br />
// GetValue() simply returns an int member from CMyObject, no calculation<br />
// method 1<br />
// repetitive calls, but no additional local variable<br />
for(int i=0; i<myArray.GetSize(); i++)<br />
{<br />
if(myArray.GetAt(i).GetValue()==1) { Function1(); }<br />
else if(myArray.GetAt(i).GetValue()==2) { Function2(); } }<br />
else { Function3(); }<br />
}<br />
<br />
// method 2<br />
// no repetitive calls, but additional local variable<br />
for(int i=0; i<myArray.GetSize(); i++)<br />
{<br />
int nValue = myArray.GetAt(i).GetValue();<br />
if(nValue==1) { Function1(); }<br />
else if(nValue==2) { Function2(); }<br />
else { Function3(); }<br />
}<br />

AnswerRe: Which of these methods is more efficient? Pin
Gary R. Wheeler8-May-04 13:39
Gary R. Wheeler8-May-04 13:39 
AnswerRe: Which of these methods is more efficient? Pin
Prakash Nadar8-May-04 22:35
Prakash Nadar8-May-04 22:35 

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.