Author: amassari
Date: Mon Jul 21 11:04:25 2008
New Revision: 678520

URL: http://svn.apache.org/viewvc?rev=678520&view=rev
Log:
Minor performance improvements

Modified:
    xerces/c/trunk/projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj
    xerces/c/trunk/src/xercesc/internal/ElemStack.cpp
    xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp

Modified: 
xerces/c/trunk/projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj?rev=678520&r1=678519&r2=678520&view=diff
==============================================================================
--- xerces/c/trunk/projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj 
(original)
+++ xerces/c/trunk/projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj Mon 
Jul 21 11:04:25 2008
@@ -1354,6 +1354,10 @@
                                >
                        </File>
                        <File
+                               
RelativePath="..\..\..\..\..\src\xercesc\util\SynchronizedStringPool.hpp"
+                               >
+                       </File>
+                       <File
                                
RelativePath="..\..\..\..\..\src\xercesc\util\TranscodingException.hpp"
                                >
                        </File>

Modified: xerces/c/trunk/src/xercesc/internal/ElemStack.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/ElemStack.cpp?rev=678520&r1=678519&r2=678520&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/ElemStack.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/ElemStack.cpp Mon Jul 21 11:04:25 2008
@@ -299,29 +299,28 @@
     unknown = false;
 
     //
+    //  If the prefix is empty, and we are in attribute mode, then we assign
+    //  it to the empty namespace because the default namespace does not
+    //  apply to attributes.
+    //
+    if (!*prefixToMap && (mode == Mode_Attribute))
+        return fEmptyNamespaceId;
+
+    //
     //  Map the prefix to its unique id, from the prefix string pool. If its
     //  not a valid prefix, then its a failure.
     //
     unsigned int prefixId = (!prefixToMap || !*prefixToMap)?fGlobalPoolId : 
fPrefixPool.getId(prefixToMap);
-    if (!prefixId)
+    if (prefixId == 0)
     {
         unknown = true;
         return fUnknownNamespaceId;
     }
-
-    //
-    //  If the prefix is empty, and we are in attribute mode, then we assign
-    //  it to the empty namespace because the default namespace does not
-    //  apply to attributes.
-    //
-    if (!*prefixToMap && (mode == Mode_Attribute))
-        return fEmptyNamespaceId;
-
     //
     //  Check for the special prefixes 'xml' and 'xmlns' since they cannot
     //  be overridden.
     //
-    if (prefixId == fXMLPoolId)
+    else if (prefixId == fXMLPoolId)
         return fXMLNamespaceId;
     else if (prefixId == fXMLNSPoolId)
         return fXMLNSNamespaceId;
@@ -330,18 +329,14 @@
     //  Start at the stack top and work backwards until we come to some
     //  element that mapped this prefix.
     //
-    int startAt = (int)(fStackTop - 1);
-    for (int index = startAt; index >= 0; index--)
+    unsigned int index, mapIndex;
+    for (index = fStackTop; index > 0; index--)
     {
         // Get a convenience pointer to the current element
-        StackElem* curRow = fStack[index];
-
-        // If no prefixes mapped at this level, then go the next one
-        if (!curRow->fMapCount)
-            continue;
+        StackElem* curRow = fStack[index-1];
 
         // Search the map at this level for the passed prefix
-        for (unsigned int mapIndex = 0; mapIndex < curRow->fMapCount; 
mapIndex++)
+        for (mapIndex = 0; mapIndex < curRow->fMapCount; mapIndex++)
         {
             if (curRow->fMap[mapIndex].fPrefId == prefixId)
                 return curRow->fMap[mapIndex].fURIId;

Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp?rev=678520&r1=678519&r2=678520&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp Mon Jul 21 
11:04:25 2008
@@ -961,17 +961,8 @@
     if (!*value)
         return;
 
-    enum States
-    {
-        InWhitespace
-        , InContent
-    };
-
-    States curState = InContent;
-
     //  Loop through the chars of the source value and normalize it
     //  according to the whitespace facet
-    bool firstNonWS = false;
     XMLCh nextCh;
     const XMLCh* srcPtr = value;
     XMLReader* fCurReader = getReaderMgr()->getCurrentReader();
@@ -982,47 +973,51 @@
         toFill.append(chSpace);
     }
 
-    while (*srcPtr)
+    if (wsFacet == DatatypeValidator::REPLACE)
     {
-        nextCh = *srcPtr;
-        if (wsFacet == DatatypeValidator::REPLACE)
+        while (*srcPtr)
         {
+            nextCh = *srcPtr++;
             if (fCurReader->isWhitespace(nextCh))
                 nextCh = chSpace;
+            // Add this char to the target buffer
+            toFill.append(nextCh);
         }
-        else // COLLAPSE case
+    }
+    else // COLLAPSE
+    {
+        enum States
         {
-            if (curState == InWhitespace)
+            InWhitespace
+            , InContent
+        };
+
+        bool firstNonWS = false;
+        States curState = InContent;
+        while (*srcPtr)
+        {
+            nextCh = *srcPtr++;
+            if (curState == InContent)
             {
-                if (!fCurReader->isWhitespace(nextCh))
-                {
-                    if (firstNonWS)
-                        toFill.append(chSpace);
-                    curState = InContent;
-                    firstNonWS = true;
-                }
-                else
+                if (fCurReader->isWhitespace(nextCh))
                 {
-                    srcPtr++;
+                    curState = InWhitespace;
                     continue;
                 }
+                firstNonWS = true;
             }
-            else if (curState == InContent)
+            else if (curState == InWhitespace)
             {
                 if (fCurReader->isWhitespace(nextCh))
-                {
-                    curState = InWhitespace;
-                    srcPtr++;
                     continue;
-                }
+                if (firstNonWS)
+                    toFill.append(chSpace);
+                curState = InContent;
                 firstNonWS = true;
             }
+            // Add this char to the target buffer
+            toFill.append(nextCh);
         }
-        // Add this char to the target buffer
-        toFill.append(nextCh);
-
-        // And move up to the next character in the source
-        srcPtr++;
     }
     if (fCurReader->isWhitespace(*(srcPtr-1)))
         fTrailing = true;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to