Click here to Skip to main content
16,008,010 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
AnswerRe: Which of these methods is more efficient? Pin
Paul Ranson9-May-04 1:15
Paul Ranson9-May-04 1:15 
AnswerRe: Which of these methods is more efficient? Pin
Ravi Bhavnani9-May-04 4:29
professionalRavi Bhavnani9-May-04 4:29 
AnswerRe: Which of these methods is more efficient? Pin
Joe Woodbury9-May-04 7:59
professionalJoe Woodbury9-May-04 7:59 
First, the line else if(myArray.GetAt(i).GetValue()==2) { Function2(); } } has an extra brace at the end.

In actual performance the two are identical since they compile to the same thing (at least in VC++ 7.1, but likely also in VC++ 6.0.)

Incidentally, using a switch statement is slightly slower. If there were additional cases, that could change.

[EDIT: At Tim correctly points out, my answer is correct only to the narrow stipulation given. Since GetValue() could involve more than the return of a simple value, it is best to get the value first then test it. The exception would be IF side effects are documented and each test depends on those side effects, though that would be a very odd solution indeed.]

Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke

GeneralRe: Which of these methods is more efficient? Pin
Tim Smith9-May-04 9:23
Tim Smith9-May-04 9:23 
GeneralRe: Which of these methods is more efficient? Pin
Joe Woodbury9-May-04 9:42
professionalJoe Woodbury9-May-04 9:42 
GeneralRe: Which of these methods is more efficient? Pin
Tim Smith9-May-04 13:47
Tim Smith9-May-04 13:47 
AnswerRe: Which of these methods is more efficient? Pin
Tim Smith9-May-04 9:27
Tim Smith9-May-04 9:27 
GeneralUsing MFC Source Code Question Pin
nm_1148-May-04 8:26
nm_1148-May-04 8:26 
GeneralRe: Using MFC Source Code Question Pin
Joe Woodbury8-May-04 8:41
professionalJoe Woodbury8-May-04 8:41 
GeneralRPC: Problem in sending data Pin
ahsan_a8-May-04 8:17
ahsan_a8-May-04 8:17 
GeneralRe: RPC: Problem in sending data Pin
ahsan_a8-May-04 12:03
ahsan_a8-May-04 12:03 
GeneralRe: RPC: Problem in sending data Pin
Gary R. Wheeler8-May-04 13:42
Gary R. Wheeler8-May-04 13:42 
QuestionAccess WindowProc in MFC? Pin
Anonymous8-May-04 7:04
Anonymous8-May-04 7:04 
GeneralVoid Pin
soul.ripper8-May-04 7:03
soul.ripper8-May-04 7:03 
GeneralRe: Void Pin
Ryan McDermott8-May-04 7:08
Ryan McDermott8-May-04 7:08 
GeneralRe: Void Pin
soul.ripper8-May-04 8:17
soul.ripper8-May-04 8:17 
GeneralRe: Void Pin
toxcct9-May-04 10:27
toxcct9-May-04 10:27 
GeneralRe: Void Pin
sps-itsec468-May-04 22:34
sps-itsec468-May-04 22:34 
GeneralRe: Void Pin
soul.ripper9-May-04 7:09
soul.ripper9-May-04 7:09 
GeneralRe: Void Pin
Anonymous9-May-04 9:30
Anonymous9-May-04 9:30 

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.