Here is the code
bool Tokenizer::SkipWhiteSpace()
{
// skip spaces, tabs, etc.
while (CurrentChar() <= _T(' ') && MoveToNextChar()) // don't check EOF when MoveToNextChar already does, also replace isspace() which calls msvcrt.dll
; // with a dirty hack: CurrentChar() <= ' ' is "good enough" here
if (IsEOF())
return false;
return true;
}
My question is: Why we should avoid a call to msvcrt.dll?
I use "dependency walker" to check "codeblocks.dll", it do depend on msvcrt.dll. See the screen shot.
Any comments? Thanks.
[attachment deleted by admin]
The idea behind avoiding a call to isspace in msvcrt.dll is for the sake of optimization. Comparing directly with "empty-space" (although it is a dirty hack, as the comment points) is a lot faster than pushing the character, saving all registers, calling the function, comparing the character, restoring all registers and returning. I think it was Thomas who changed that, and it improved performance. No other reasons for it.
Quote from: Ceniza on April 05, 2009, 03:21:06 PM
The idea behind avoiding a call to isspace in msvcrt.dll is for the sake of optimization. Comparing directly with "empty-space" (although it is a dirty hack, as the comment points) is a lot faster than pushing the character, saving all registers, calling the function, comparing the character, restoring all registers and returning. I think it was Thomas who changed that, and it improved performance. No other reasons for it.
Thanks for your answer.
By the way, I thought carefully why it didn't use equal comparing instead.
Finally I realized that
CurrentChar() <= _T(' ')
also skips _T('\n'), that can't be done by calling isspace().