From ee525dba4d4b9287cff7b6a3cdff7b39bfacf75e Mon Sep 17 00:00:00 2001 From: JayXon Date: Wed, 24 Dec 2014 04:01:42 -0500 Subject: [PATCH] Simplify ParseName Only the first char needs to be checked with IsNameStartChar, so check it before the loop. --- tinyxml2.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 7b975c9..dfb6831 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -140,18 +140,18 @@ char* StrPair::ParseName( char* p ) if ( !p || !(*p) ) { return 0; } + if ( !XMLUtil::IsNameStartChar( *p ) ) { + return 0; + } char* const start = p; - - while( *p && ( p == start ? XMLUtil::IsNameStartChar( *p ) : XMLUtil::IsNameChar( *p ) )) { + ++p; + while ( *p && XMLUtil::IsNameChar( *p ) ) { ++p; } - if ( p > start ) { - Set( start, p, 0 ); - return p; - } - return 0; + Set( start, p, 0 ); + return p; }