Click here to Skip to main content
15,888,984 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Performance woes. I'm appalled. Pin
harold aptroot26-Dec-20 4:58
harold aptroot26-Dec-20 4:58 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch26-Dec-20 5:28
mvahoney the codewitch26-Dec-20 5:28 
GeneralRe: Performance woes. I'm appalled. Pin
Daniel Pfeffer26-Dec-20 7:08
professionalDaniel Pfeffer26-Dec-20 7:08 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch26-Dec-20 8:12
mvahoney the codewitch26-Dec-20 8:12 
GeneralRe: Performance woes. I'm appalled. Pin
trønderen26-Dec-20 9:01
trønderen26-Dec-20 9:01 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch26-Dec-20 10:19
mvahoney the codewitch26-Dec-20 10:19 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch26-Dec-20 16:57
mvahoney the codewitch26-Dec-20 16:57 
GeneralRe: Performance woes. I'm appalled. Pin
trønderen26-Dec-20 18:50
trønderen26-Dec-20 18:50 
If switching on a char takes an inordinate amount of time, I'd sure be curious to know how your compiler does it. It ought to be the most efficient way of switching there is: A jump table indexed by the switch variable, loading the program counter. In the old days, when CPUs were slow, that was the only way to do it. (The first Pascal compiler I used could only take alternatives spanning a 256-value range, because that was the largest jump table it could generate.)

Modern languages are far more flexible in their case expressions, often requiring the compiler to generate code like for an "if - elseif - elseif ... else" sequence. Maybe that is what your compiler has done here, maybe even generating "elseif"s for every char value, rather than collecting the "default" in an "else". If the compiler is scared of big jump tables, and therefore uses elseif-constructions, it rather should realize that this makes the code size grow far more than the size of a jump table!

I am just guessing! But it sounds crazy that an indexed jump would kill your performance; it just doesn't sound right. I would look at the generated code to see what happens. If you can't make the compiler do an indexed jump, maybe you are better off writing it in longhand, building the jump table from labels Smile | :) .

I guess that writing it explicitly as "if - elseif..." would be better. Then you could also do the most common case first, so that only a single test is required: "if (ch > '\t') {...}".

I hate it when compilers force me to do the job that should be theirs, but maybe you have to, in this case!
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch27-Dec-20 0:55
mvahoney the codewitch27-Dec-20 0:55 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch27-Dec-20 1:05
mvahoney the codewitch27-Dec-20 1:05 
GeneralRe: Performance woes. I'm appalled. Pin
Josh Gray228-Dec-20 1:47
Josh Gray228-Dec-20 1:47 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch28-Dec-20 2:02
mvahoney the codewitch28-Dec-20 2:02 
GeneralRe: Performance woes. I'm appalled. Pin
Jörgen Andersson27-Dec-20 3:45
professionalJörgen Andersson27-Dec-20 3:45 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch27-Dec-20 4:07
mvahoney the codewitch27-Dec-20 4:07 
GeneralRe: Performance woes. I'm appalled. Pin
Jörgen Andersson27-Dec-20 4:13
professionalJörgen Andersson27-Dec-20 4:13 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch27-Dec-20 4:31
mvahoney the codewitch27-Dec-20 4:31 
GeneralRe: Performance woes. I'm appalled. Pin
Jörgen Andersson27-Dec-20 4:51
professionalJörgen Andersson27-Dec-20 4:51 
GeneralRe: Performance woes. I'm appalled. Pin
Gerry Schmitz26-Dec-20 15:19
mveGerry Schmitz26-Dec-20 15:19 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch26-Dec-20 16:49
mvahoney the codewitch26-Dec-20 16:49 
GeneralRe: Performance woes. I'm appalled. Pin
k505427-Dec-20 3:34
mvek505427-Dec-20 3:34 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch27-Dec-20 3:56
mvahoney the codewitch27-Dec-20 3:56 
GeneralRe: Performance woes. I'm appalled. Pin
obermd28-Dec-20 3:45
obermd28-Dec-20 3:45 
GeneralRe: Performance woes. I'm appalled. Pin
honey the codewitch28-Dec-20 3:47
mvahoney the codewitch28-Dec-20 3:47 
GeneralFun with Java Pin
Cp-Coder25-Dec-20 13:09
Cp-Coder25-Dec-20 13:09 
GeneralRe: Fun with Java Pin
Richard MacCutchan25-Dec-20 21:12
mveRichard MacCutchan25-Dec-20 21:12 

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.