Hacker News new | ask | show | jobs
by superdimwit 2937 days ago
Could you try and reorder the state checks to occur with decreasing state-transition probability? I.e. if I am currently in code, it is most likely that I will be in code next state as well, a bit less likely that I'll be in a single line comment, and even less likely that I'll be in a multiline comment. If I'm in a multiline comment, I will most likely be in a multiline comment next, or code, but unlikely to be in a single line comment.

Amongst a few equiprobable state transitions, ordering the checks by increasing expense might also help.

1 comments

I did toy with that a bit but don’t remember it making any difference. I might try it again though. From memory though it might work better to move he switch to a hash which should allow it to compile down to a jump table which would be faster.