Menu

Minor performance improvement: IsWhiteSpace

Developer
2007-04-17
2013-05-20
  • Greg Bullock

    Greg Bullock - 2007-04-17

    I believe the TiXmlBase class's method

        inline static bool IsWhiteSpace( char c )       
        {
            return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
        }

    may be safely shortened to

        inline static bool IsWhiteSpace( char c )       
        {
            return ( isspace( (unsigned char) c ) );
        }

    as I believe the C++ isspace function already explicitly checks for '\n' and '\r' as well as other characters (such as '\t', ' ', etc.).

    If someone knows otherwise, I'd be most interested to hear it.

    Regards.
    Greg

     
    • Lee Thomason

      Lee Thomason - 2007-04-30

      I can't remember if I put that in there to fix a compiler bug or because I made a mistake. Fear of the former has kept me from fixing it...

      lee

       

Log in to post a comment.