Click here to Skip to main content
16,011,805 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Number of characters of a string Pin
CodingLover17-Dec-07 23:01
CodingLover17-Dec-07 23:01 
JokeRe: Number of characters of a string Pin
CPallini17-Dec-07 23:12
mveCPallini17-Dec-07 23:12 
GeneralRe: Number of characters of a string Pin
CodingLover17-Dec-07 23:31
CodingLover17-Dec-07 23:31 
GeneralRe: Number of characters of a string Pin
cp987617-Dec-07 23:37
cp987617-Dec-07 23:37 
GeneralRe: Number of characters of a string Pin
CPallini18-Dec-07 0:04
mveCPallini18-Dec-07 0:04 
GeneralRe: Number of characters of a string Pin
cp987618-Dec-07 0:15
cp987618-Dec-07 0:15 
GeneralRe: Number of characters of a string Pin
CPallini18-Dec-07 0:43
mveCPallini18-Dec-07 0:43 
GeneralRe: Number of characters of a string Pin
cp987618-Dec-07 10:07
cp987618-Dec-07 10:07 
CPallini wrote:
In fact there is no difference at all, in the code snippet shown


There is - and depending on the distribution of characters one will be better than the other. My suspicion is that on normal text that the case statement will perform very slightly worse. Note that in the if statement all three tests are always performed. In the case statement the compiler analyses the case values and provides a short-cut if the value is < 9 - all other testing is bypassed. It was a good try and it didn't know that the data was positive, so providing a shortcut if the value was > D would have provided significantly better performance.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

GeneralYou're right Pin
CPallini18-Dec-07 12:33
mveCPallini18-Dec-07 12:33 
GeneralRe: Number of characters of a string Pin
CodingLover18-Dec-07 0:18
CodingLover18-Dec-07 0:18 
GeneralRe: Number of characters of a string Pin
Maxwell Chen18-Dec-07 1:16
Maxwell Chen18-Dec-07 1:16 
QuestionRe: Number of characters of a string Pin
David Crow18-Dec-07 3:20
David Crow18-Dec-07 3:20 
GeneralRe: Number of characters of a string Pin
David Crow18-Dec-07 3:30
David Crow18-Dec-07 3:30 
GeneralRe: Number of characters of a string Pin
jhwurmbach18-Dec-07 4:05
jhwurmbach18-Dec-07 4:05 
GeneralRe: Number of characters of a string Pin
David Crow18-Dec-07 4:14
David Crow18-Dec-07 4:14 
GeneralRe: Number of characters of a string Pin
jhwurmbach18-Dec-07 4:29
jhwurmbach18-Dec-07 4:29 
QuestionHow to read only the integer value of a txt file in C++ Pin
Cabomba17-Dec-07 20:20
Cabomba17-Dec-07 20:20 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Peter Weyzen17-Dec-07 20:48
Peter Weyzen17-Dec-07 20:48 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba17-Dec-07 21:36
Cabomba17-Dec-07 21:36 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Iain Clarke, Warrior Programmer17-Dec-07 23:48
Iain Clarke, Warrior Programmer17-Dec-07 23:48 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba18-Dec-07 19:50
Cabomba18-Dec-07 19:50 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Iain Clarke, Warrior Programmer18-Dec-07 23:56
Iain Clarke, Warrior Programmer18-Dec-07 23:56 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba20-Dec-07 3:51
Cabomba20-Dec-07 3:51 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Iain Clarke, Warrior Programmer20-Dec-07 23:56
Iain Clarke, Warrior Programmer20-Dec-07 23:56 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba14-Jan-08 19:21
Cabomba14-Jan-08 19:21 

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.