Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Question on Tokenizer::SkipWhiteSpace

(1/1)

ollydbg:
Here is the code

--- 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;
}
--- End code ---

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]

Ceniza:
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.

ollydbg:

--- 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.

--- End quote ---

Thanks for your answer.

By the way, I thought carefully why it didn't use equal comparing instead.
Finally  I realized that


--- Code: ---CurrentChar() <= _T(' ')

--- End code ---

also skips _T('\n'), that can't be done by calling isspace().

Navigation

[0] Message Index

Go to full version