Simplify ParseName
Only the first char needs to be checked with IsNameStartChar, so check
it before the loop.
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 7b975c9..dfb6831 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -140,18 +140,18 @@
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;
}