From f1de65ca561a403b544ff6d849fa3b86ab8d02ec Mon Sep 17 00:00:00 2001
From: Alberto Massari <amassari@apache.org>
Date: Wed, 23 Jul 2008 08:57:00 +0000
Subject: [PATCH] Performance improvement

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@679033 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/internal/XMLReader.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/xercesc/internal/XMLReader.cpp b/src/xercesc/internal/XMLReader.cpp
index bd0357987..7cf06b498 100644
--- a/src/xercesc/internal/XMLReader.cpp
+++ b/src/xercesc/internal/XMLReader.cpp
@@ -750,10 +750,14 @@ bool XMLReader::getQName(XMLBuffer& toFill, int* colonPosition)
             }
         }
 
-        while (fCharIndex < fCharsAvail) {
-            //  Check the current char and take it if its a name char. Else
+        while(true)
+        {
+            //  Check the current char and take it if it's a name char. Else
             //  break out.
-            if ( (fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F) )
+            for (;(fCharIndex < fCharsAvail) && ((fgCharCharsTable[fCharBuf[fCharIndex]] & gNCNameCharMask) != 0);fCharIndex++);
+
+            // if it isn't a NameChar, it could be a surrogate
+            if ( (fCharIndex < fCharsAvail) && (fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F) )
             {
                 // make sure one more char is in the buffer, the transcoder
                 // should put only a complete surrogate pair into the buffer
@@ -767,11 +771,7 @@ bool XMLReader::getQName(XMLBuffer& toFill, int* colonPosition)
                 fCharIndex += 2;
                 continue;
             }
-
-            if ((fgCharCharsTable[fCharBuf[fCharIndex]] & gNCNameCharMask) == 0)
-                break;
-
-            fCharIndex++;
+            break;
         }
 
         // we have to copy the accepted character(s), and update column
-- 
GitLab