dbertoni    00/11/20 12:04:41

  Modified:    c/src/PlatformSupport AttributeListImpl.cpp
                        AttributeListImpl.hpp DOMStringHelper.cpp
                        DOMStringHelper.hpp DOMStringPrintWriter.cpp
               c/src/XPath FunctionConcat.cpp FunctionNormalizeSpace.cpp
                        FunctionString.cpp FunctionSubstring.cpp
                        FunctionSubstringAfter.cpp
                        FunctionSubstringBefore.cpp FunctionTranslate.cpp
                        XObjectFactory.hpp XObjectFactoryDefault.cpp
                        XObjectFactoryDefault.hpp XPathExecutionContext.hpp
                        XPathExecutionContextDefault.cpp
                        XPathExecutionContextDefault.hpp XString.cpp
                        XString.hpp XStringAllocator.cpp
                        XStringAllocator.hpp
               c/src/XSLT ElemAttribute.cpp ElemComment.cpp ElemMessage.cpp
                        ElemPI.cpp ElemTemplateElement.cpp ElemValueOf.cpp
                        FunctionGenerateID.cpp FunctionGenerateID.hpp
                        StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
                        StylesheetRoot.cpp XSLTEngineImpl.cpp
                        XSLTEngineImpl.hpp
  Log:
  Performance enhancements.
  
  Revision  Changes    Path
  1.15      +49 -11    xml-xalan/c/src/PlatformSupport/AttributeListImpl.cpp
  
  Index: AttributeListImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/AttributeListImpl.cpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AttributeListImpl.cpp     2000/11/02 01:45:34     1.14
  +++ AttributeListImpl.cpp     2000/11/20 20:04:25     1.15
  @@ -74,7 +74,8 @@
   
   AttributeListImpl::AttributeListImpl() :
        AttributeList(),
  -     m_AttributeVector()
  +     m_AttributeVector(),
  +     m_cacheVector()
   {
   }
   
  @@ -84,6 +85,10 @@
   {
        // Clean up everything...
        clear();
  +
  +     assert(m_AttributeVector.empty() == true);
  +
  +     deleteEntries(m_cacheVector);
   }
   
   
  @@ -157,10 +162,16 @@
                        // Copy the vector entries, and build the index map...
                        for(const_iterator i = theRHS.m_AttributeVector.end(); 
i != theEnd; ++i)
                        {
  -                             assert(*i != 0);
  +                             AttributeVectorEntry* const             
theEntry = *i;
  +
  +                             assert(theEntry != 0);
   
                                // Add the item...
  -                             tempVector.push_back(new 
AttributeVectorEntry(**i));
  +                             tempVector.push_back(
  +                                     getNewEntry(
  +                                             theEntry->m_Name.begin(),
  +                                             theEntry->m_Type.begin(),
  +                                             theEntry->m_Value.begin()));
                        }
   
                        // OK, we're safe, so swap the contents of the
  @@ -337,19 +348,14 @@
   void
   AttributeListImpl::clear()
   {
  -#if !defined(XALAN_NO_NAMESPACES)
  -     using std::for_each;
  -#endif
  +     m_cacheVector.insert(m_cacheVector.end(), m_AttributeVector.begin(), 
m_AttributeVector.end());
   
  -     deleteEntries(m_AttributeVector);
  -
        // Clear everything out.
        m_AttributeVector.clear();
   }
   
   
   
  -
   // A convenience function to find the length of a null-terminated
   // array of XMLChs
   inline const XMLCh*
  @@ -434,7 +440,7 @@
                        m_AttributeVector.reserve(eDefaultVectorSize);
                }
   
  -             XalanAutoPtr<AttributeVectorEntry>      theEntry(new 
AttributeVectorEntry(name, value, type));
  +             XalanAutoPtr<AttributeVectorEntry>      
theEntry(getNewEntry(name, type, value));
   
                // Add the new one.
                m_AttributeVector.push_back(theEntry.get());
  @@ -451,6 +457,37 @@
   
   
   
  +AttributeListImpl::AttributeVectorEntry*
  +AttributeListImpl::getNewEntry(
  +                     const XMLCh*    name,
  +                     const XMLCh*    type,
  +                     const XMLCh*    value)
  +{
  +     if (m_cacheVector.size() == 0)
  +     {
  +             return new AttributeVectorEntry(name, value, type);
  +     }
  +     else
  +     {
  +             AttributeVectorEntry* const             theEntry =
  +                     m_cacheVector.back();
  +
  +             theEntry->clear();
  +
  +             assert(theEntry->m_Name.size() == 0 && theEntry->m_Value.size() 
== 0 && theEntry->m_Type.size() == 0);
  +
  +             theEntry->m_Name.insert(theEntry->m_Name.begin(), name, 
endArray(name) + 1);
  +             theEntry->m_Value.insert(theEntry->m_Value.begin(), value, 
endArray(value) + 1);
  +             theEntry->m_Type.insert(theEntry->m_Type.begin(), type, 
endArray(type) + 1);
  +
  +             m_cacheVector.pop_back();
  +
  +             return theEntry;
  +     }
  +}
  +
  +
  +
   bool
   AttributeListImpl::removeAttribute(const XMLCh*              name)
   {
  @@ -471,9 +508,10 @@
   
        if (i != m_AttributeVector.end())
        {
  -             delete *i;
  +             m_cacheVector.push_back(*i);
   
                m_AttributeVector.erase(i);
  +
                fResult = true;
        }
   
  
  
  
  1.13      +22 -5     xml-xalan/c/src/PlatformSupport/AttributeListImpl.hpp
  
  Index: AttributeListImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/AttributeListImpl.hpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AttributeListImpl.hpp     2000/11/02 01:45:34     1.12
  +++ AttributeListImpl.hpp     2000/11/20 20:04:25     1.13
  @@ -134,9 +134,10 @@
         * @param value  attribute value
         */
        virtual bool
  -     addAttribute(const XMLCh*       name,
  -                              const XMLCh*   type,
  -                              const XMLCh*   value);
  +     addAttribute(
  +                     const XMLCh*    name,
  +                     const XMLCh*    type,
  +                     const XMLCh*    value);
   
        /**
         * Removes an attribute from the attribute list
  @@ -197,6 +198,14 @@
                {
                }
   
  +             void
  +             clear()
  +             {
  +                     m_Name.clear();
  +                     m_Value.clear();
  +                     m_Type.clear();
  +             }
  +
                XMLChVectorType         m_Name;
                XMLChVectorType         m_Value;
                XMLChVectorType         m_Type;
  @@ -206,10 +215,10 @@
   
   #if defined(XALAN_NO_NAMESPACES)
        // This vector will hold the entries.
  -     typedef vector<AttributeVectorEntry*>                           
AttributeVectorType;
  +     typedef vector<AttributeVectorEntry*>                   
AttributeVectorType;
   #else
        // This vector will hold the entries.
  -     typedef std::vector<AttributeVectorEntry*>                              
AttributeVectorType;
  +     typedef std::vector<AttributeVectorEntry*>              
AttributeVectorType;
   #endif
   
   private:
  @@ -224,11 +233,19 @@
                eDefaultVectorSize = 5
        };
   
  +     AttributeVectorEntry*
  +     getNewEntry(
  +                     const XMLCh*    name,
  +                     const XMLCh*    type,
  +                     const XMLCh*    value);
  +
        // Helper function to delete entries...
        static void
        deleteEntries(AttributeVectorType&      theVector);
   
        AttributeVectorType             m_AttributeVector;
  +
  +     AttributeVectorType             m_cacheVector;
   };
   
   
  
  
  
  1.43      +15 -13    xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp
  
  Index: DOMStringHelper.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- DOMStringHelper.cpp       2000/11/02 22:25:37     1.42
  +++ DOMStringHelper.cpp       2000/11/20 20:04:25     1.43
  @@ -1732,8 +1732,10 @@
   
   
   
  -XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
  -UnsignedLongToDOMString(unsigned long        theUnsignedLong)
  +XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
  +UnsignedLongToDOMString(
  +                     unsigned long           theValue,
  +                     XalanDOMString&         theResult)
   {
   #if 1
   
  @@ -1751,14 +1753,14 @@
                --thePointer;
   
                // Isolate the left most character.
  -             *thePointer = XalanDOMChar(theUnsignedLong % 10 + 
XalanUnicode::charDigit_0);
  +             *thePointer = XalanDOMChar(theValue % 10 + 
XalanUnicode::charDigit_0);
   
                // OK, we're done with it...
  -             theUnsignedLong /= 10;
  +             theValue /= 10;
        }
  -     while(theUnsignedLong != 0);
  +     while(theValue != 0);
   
  -     return XalanDOMString(thePointer, theEnd - thePointer);
  +     assign(theResult, thePointer, theEnd - thePointer);
   
   #elif defined(XALAN_USE_WCHAR_SUPPORT)
   
  @@ -1766,9 +1768,9 @@
   
        swprintf(theBuffer,
                         L"%lu",
  -                      theUnsignedLong);
  +                      theValue);
   
  -     return XalanDOMString(theBuffer, length(theBuffer));
  +     assign(theResult, theBuffer, length(theBuffer));
   
   #else
   
  @@ -1776,19 +1778,19 @@
   
        ostrstream      theFormatter(theBuffer, sizeof(theBuffer));
   
  -     theFormatter << theUnsignedLong << '\0';
  +     theFormatter << theValue << '\0';
   
  -     XalanDOMChar    theResult[MAX_PRINTF_DIGITS + 1];
  +     XalanDOMChar    theWideBuffer[MAX_PRINTF_DIGITS + 1];
   
        const unsigned int      theLength = length(theBuffer);
   
   #if defined(XALAN_NO_ALGORITHMS_WITH_BUILTINS)
  -     XalanCopy(theBuffer, theBuffer + theLength, theResult);
  +     XalanCopy(theBuffer, theBuffer + theLength, theWideBuffer);
   #else
  -     copy(theBuffer, theBuffer + theLength, theResult);
  +     copy(theBuffer, theBuffer + theLength, theWideBuffer);
   #endif
   
  -     return XalanDOMString(theResult, theLength);
  +     assign(theResult, theWideBuffer, theLength);
   #endif
   }
   
  
  
  
  1.33      +97 -13    xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp
  
  Index: DOMStringHelper.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- DOMStringHelper.hpp       2000/11/02 01:45:35     1.32
  +++ DOMStringHelper.hpp       2000/11/20 20:04:25     1.33
  @@ -612,13 +612,13 @@
   
   
   /**
  - * Converts a long value into a XalanDOMString
  + * Converts an unsigned long value into a XalanDOMString
    * 
  - * @param theInt number to be converted
  + * @param theUnsignedLong number to be converted
    * @return hexadecimal string representation of the number
    */
   XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
  -UnsignedLongToHexDOMString(unsigned long     theUnsignedLong);
  +UnsignedLongToHexDOMString(unsigned long     theValue);
   
   
   
  @@ -629,7 +629,20 @@
    * @return decimal string representation of the number
    */
   XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
  -LongToDOMString(long theLong);
  +LongToDOMString(long theValue);
  +
  +
  +
  +/**
  + * Converts an unsigned long value into a XalanDOMString
  + * 
  + * @param theValue number to be converted
  + * @param theString The string for the result.
  + */
  +XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
  +UnsignedLongToDOMString(
  +                     unsigned long           theValue,
  +                     XalanDOMString&         theResult);
   
   
   
  @@ -639,11 +652,18 @@
    * @param theInt number to be converted
    * @return decimal string representation of the number
    */
  -XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
  -UnsignedLongToDOMString(unsigned long        theInt);
  +inline const XalanDOMString
  +UnsignedLongToDOMString(unsigned long        theValue)
  +{
  +     XalanDOMString  theResult;
   
  +     UnsignedLongToDOMString(theValue, theResult);
  +
  +     return theResult;
  +}
   
   
  +
   /**
    * Converts a wide string into an integer value
    * 
  @@ -1896,23 +1916,78 @@
   
   
   /**
  + * Assign one string to another
  + * 
  + * @param theString         target string
  + * @param theStringToAppend string to assign
  + * @param theStringToAppendLength length of the string (-1 implies the 
string is null-terminated)
  + * @return a reference to the target string
  + */
  +inline XalanDOMString&
  +assign(
  +                     XalanDOMString&                 theString,
  +                     const XalanDOMChar*             theStringToAssign,
  +                     unsigned int                    theStringToAssignLength 
= -1)
  +{
  +#if defined(XALAN_USE_CUSTOM_STRING) || defined(XALAN_USE_STD_STRING)
  +     if (theStringToAssignLength == unsigned(-1))
  +     {
  +             theString.assign(theStringToAssign);
  +     }
  +     else
  +     {
  +             theString.assign(theStringToAssign, theStringToAssignLength);
  +     }
  +#else
  +     if (theStringToAssignLength == unsigned(-1))
  +     {
  +             theString = XalanDOMString(theStringToAssign);
  +     }
  +     else
  +     {
  +             theString = XalanDOMString(theStringToAssign, 
theStringToAssignLength);
  +     }
  +#endif
  +
  +     return theString;
  +}
  +
  +
  +
  +/**
    * Concatenate two strings
    * 
    * @param theString         target string
    * @param theStringToAppend string to add to target
  - * @return string with contents of 'theStringToAppend' added to target string
  + * @param theStringToAppendLength length of the string (-1 implies the 
string is null-terminated)
  + * @return a reference to the target string
    */
   inline XalanDOMString&
   append(
                        XalanDOMString&                 theString,
  -                     const XalanDOMChar*             theStringToAppend)
  +                     const XalanDOMChar*             theStringToAppend,
  +                     unsigned int                    theStringToAppendLength 
= -1)
   {
        assert(theStringToAppend != 0);
   
   #if defined(XALAN_USE_CUSTOM_STRING) || defined(XALAN_USE_STD_STRING)
  -     theString.append(theStringToAppend);
  +     if (theStringToAppendLength == unsigned(-1))
  +     {
  +             theString.append(theStringToAppend);
  +     }
  +     else
  +     {
  +             theString.append(theStringToAppend, theStringToAppendLength);
  +     }
   #else
  -     theString.appendData(theStringToAppend);
  +     if (theStringToAppendLength == unsigned(-1))
  +     {
  +             theString.appendData(theStringToAppend);
  +     }
  +     else
  +     {
  +             append(theString, XalanDOMString(theStringToAppend, 
theStringToAppendLength);
  +     }
   #endif
   
        return theString;
  @@ -1925,17 +2000,26 @@
    * 
    * @param theString         target string
    * @param theStringToAppend string to add to target
  + * @param theStringToAppendLength length of the string (-1 implies the 
string is null-terminated)
    * @return string with contents of 'theStringToAppend' added to target string
    */
   inline XalanDOMString&
   append(
                        XalanDOMString&         theString,
  -                     const char*                     theStringToAppend)
  +                     const char*                     theStringToAppend,
  +                     unsigned int            theStringToAppendLength = -1)
   {
   #if defined(XALAN_USE_CUSTOM_STRING) || defined(XALAN_USE_STD_STRING)
  -     theString.append(TranscodeFromLocalCodePage(theStringToAppend));
  +             theString.append(TranscodeFromLocalCodePage(theStringToAppend, 
theStringToAppendLength));
   #else
  -     theString.appendData(theStringToAppend);
  +     if (theStringToAppendLength == unsigned(-1))
  +     {
  +             theString.appendData(theStringToAppend);
  +     }
  +     else
  +     {
  +             append(theString, XalanDOMString(theStringToAppend, 
theStringToAppendLength);
  +     }
   #endif
   
        return theString;
  
  
  
  1.9       +5 -19     xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.cpp
  
  Index: DOMStringPrintWriter.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DOMStringPrintWriter.cpp  2000/11/02 01:45:35     1.8
  +++ DOMStringPrintWriter.cpp  2000/11/20 20:04:26     1.9
  @@ -127,25 +127,7 @@
        assert(s != 0);
        assert(theLength == UINT_MAX || length(s) >= theOffset + theLength);
   
  -     if (theLength == UINT_MAX)
  -     {
  -                     m_outputString += (s + theOffset);
  -     }
  -     else
  -     {
  -             vector<XalanDOMChar>    theBuffer(theLength + 1, 0);
  -
  -             // We'll copy the characters into the vector first.
  -             copy(s + theOffset,
  -                      s + theOffset + theLength,
  -                      theBuffer.begin());
  -
  -             // Now append a terminated 0.
  -             theBuffer.back() = 0;
  -
  -             // Now append the data.
  -             m_outputString += theBuffer.begin();
  -     }
  +     append(m_outputString, (s + theOffset), theLength);
   }
   
   
  @@ -153,6 +135,7 @@
   void
   DOMStringPrintWriter::write(XalanDOMChar     c)
   {
  +#if defined(XALAN_USE_XERCES_DOMSTRING)
        // Write the data as a null-terminated array,
        // so we can guarantee null-termination of our
        // string...
  @@ -161,6 +144,9 @@
        theBuffer[0] = c;
   
        m_outputString += theBuffer;
  +#else
  +     m_outputString += c;
  +#endif
   }
   
   
  
  
  
  1.4       +23 -10    xml-xalan/c/src/XPath/FunctionConcat.cpp
  
  Index: FunctionConcat.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionConcat.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FunctionConcat.cpp        2000/11/10 16:22:24     1.3
  +++ FunctionConcat.cpp        2000/11/20 20:04:29     1.4
  @@ -75,16 +75,19 @@
                XPathExecutionContext&                  executionContext,
                XalanNode*                                              /* 
context */,                  
                const XObject*                                  arg1,
  -             const XObject*                                  arg2,
  -             const XObject*                                  arg3)
  +             const XObject*                                  arg2)
   {
  -     assert(arg1 != 0 || arg2 != 0 || arg3 != 0);    
  +     assert(arg1 != 0 && arg2 != 0); 
        
        XalanDOMString  theResult;
  +
  +     const XalanDOMString&   theArg1 = arg1->str();
  +     const XalanDOMString&   theArg2 = arg2->str();
  +
  +     reserve(theResult, length(theArg1) + length(theArg2) + 1);
   
  -     theResult += arg1->str();
  -     theResult += arg2->str();
  -     theResult += arg3->str();       
  +     theResult += theArg1;
  +     theResult += theArg2;
   
        return executionContext.getXObjectFactory().createString(theResult);
   }
  @@ -96,14 +99,22 @@
                XPathExecutionContext&                  executionContext,
                XalanNode*                                              /* 
context */,                  
                const XObject*                                  arg1,
  -             const XObject*                                  arg2)
  +             const XObject*                                  arg2,
  +             const XObject*                                  arg3)
   {
  -     assert(arg1 != 0 || arg2 != 0); 
  +     assert(arg1 != 0 && arg2 != 0 && arg3 != 0);    
        
        XalanDOMString  theResult;
   
  -     theResult += arg1->str();
  -     theResult += arg2->str();
  +     const XalanDOMString&   theArg1 = arg1->str();
  +     const XalanDOMString&   theArg2 = arg2->str();
  +     const XalanDOMString&   theArg3 = arg3->str();
  +
  +     reserve(theResult, length(theArg1) + length(theArg2) + length(theArg3) 
+ 1);
  +
  +     theResult += theArg1;
  +     theResult += theArg2;
  +     theResult += theArg3;
   
        return executionContext.getXObjectFactory().createString(theResult);
   }
  @@ -126,6 +137,8 @@
   
                for(; i != theEnd; ++i)
                {
  +                     assert(*i != 0);
  +
                        theCombinedLength += length((*i)->str());
                }
        }
  
  
  
  1.4       +9 -16     xml-xalan/c/src/XPath/FunctionNormalizeSpace.cpp
  
  Index: FunctionNormalizeSpace.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNormalizeSpace.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FunctionNormalizeSpace.cpp        2000/11/10 16:22:24     1.3
  +++ FunctionNormalizeSpace.cpp        2000/11/20 20:04:30     1.4
  @@ -88,12 +88,12 @@
                XPathExecutionContext&                  executionContext,
                XalanNode*                                              context)
   {
  -     XalanDOMString  theSourceString;
  -
        if (context == 0)
        {
                executionContext.error("The normalize-space() function requires 
a non-null context node!",
                                                           context);
  +
  +             return 0;
        }
        else
        {
  @@ -107,29 +107,23 @@
                XObjectGuard    theXObject(executionContext.getXObjectFactory(),
                                                                
executionContext.createNodeSet(*context));
   
  -             // Now, get the string from the XObject.
  -             theSourceString = theXObject->str();            
  +             return normalize(executionContext, theXObject->str());
        }
  -
  -     return normalize(executionContext, theSourceString);
   }
   
   
  +
   XObject*
   FunctionNormalizeSpace::normalize(
                XPathExecutionContext&  executionContext,
                const XalanDOMString&   theString)
   {
  -     const unsigned int              theStringLength = length(theString);
  +     const unsigned int      theStringLength = length(theString);
   
  -     XalanDOMChar                    thePreviousChar = 0;
  +     XalanDOMChar            thePreviousChar = 0;
   
        // A vector to contain the new characters.  We'll use it to construct
        // the result string.
  -#if !defined(XALAN_NO_NAMESPACES)
  -     using std::vector;
  -#endif
  -
   #if defined(XALAN_NO_NAMESPACES)
        typedef vector<XalanDOMChar>            VectorType;
   #else
  @@ -137,7 +131,7 @@
   #endif
   
        // A vector to contain the result.
  -     VectorType                              theVector;
  +     VectorType      theVector;
   
        // The result string can only be as large as the source string, so
        // just reserve the space now.
  @@ -176,11 +170,11 @@
        {
                if (isXMLWhitespace(theVector.back()) == true)
                {
  -                     // The last character is a space, so remove it
  +                     // The last character is a space, so remove it...
                        --theSize;
                }
   
  -             return 
executionContext.getXObjectFactory().createString(XalanDOMString(theVector.begin(),
 theSize));
  +             return 
executionContext.getXObjectFactory().createString(theVector.begin(), theSize);
        }
   }
   
  @@ -204,4 +198,3 @@
        return XALAN_STATIC_UCODE_STRING(
                "The normalize-space() function takes zero arguments or one 
argument!");
   }
  -
  
  
  
  1.3       +3 -6      xml-xalan/c/src/XPath/FunctionString.cpp
  
  Index: FunctionString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionString.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FunctionString.cpp        2000/11/10 16:22:24     1.2
  +++ FunctionString.cpp        2000/11/20 20:04:30     1.3
  @@ -88,11 +88,11 @@
                XPathExecutionContext&                  executionContext,
                XalanNode*                                              context)
   {
  -     XalanDOMString  theValue;
  -
        if (context == 0)
        {
                executionContext.error("The string() function requires a 
non-null context node!");
  +
  +             return 0;
        }
        else
        {
  @@ -108,11 +108,8 @@
                XObjectGuard    theXObject(executionContext.getXObjectFactory(),
                                                                   
executionContext.createNodeSet(*context));
   
  -             // Get the value of the theXObject...
  -             theValue = theXObject->str();
  +             return 
executionContext.getXObjectFactory().createString(theXObject->str());
        }
  -
  -     return executionContext.getXObjectFactory().createString(theValue);
   }
   
   
  
  
  
  1.4       +1 -2      xml-xalan/c/src/XPath/FunctionSubstring.cpp
  
  Index: FunctionSubstring.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstring.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FunctionSubstring.cpp     2000/11/10 16:22:24     1.3
  +++ FunctionSubstring.cpp     2000/11/20 20:04:30     1.4
  @@ -148,8 +148,7 @@
        }
        else
        {
  -             return executionContext.getXObjectFactory().createString(
  -                     XalanDOMString(theBuffer.begin(), theSize));
  +             return 
executionContext.getXObjectFactory().createString(theBuffer.begin(), theSize);
        }
   }
   
  
  
  
  1.4       +1 -1      xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp
  
  Index: FunctionSubstringAfter.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FunctionSubstringAfter.cpp        2000/11/10 16:22:24     1.3
  +++ FunctionSubstringAfter.cpp        2000/11/20 20:04:30     1.4
  @@ -119,7 +119,7 @@
        }
        else
        {
  -             return 
executionContext.getXObjectFactory().createString(XalanDOMString(theBuffer.begin(),
 theSize));
  +             return 
executionContext.getXObjectFactory().createString(theBuffer.begin(), theSize);
        }
   }
   
  
  
  
  1.4       +1 -2      xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp
  
  Index: FunctionSubstringBefore.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FunctionSubstringBefore.cpp       2000/11/10 16:22:24     1.3
  +++ FunctionSubstringBefore.cpp       2000/11/20 20:04:30     1.4
  @@ -116,8 +116,7 @@
        }
        else
        {
  -             return 
executionContext.getXObjectFactory().createString(XalanDOMString(
  -                     theBuffer.begin(), theSize));
  +             return 
executionContext.getXObjectFactory().createString(theBuffer.begin(), theSize);
        }
   }
   
  
  
  
  1.4       +1 -1      xml-xalan/c/src/XPath/FunctionTranslate.cpp
  
  Index: FunctionTranslate.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionTranslate.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FunctionTranslate.cpp     2000/11/10 16:22:24     1.3
  +++ FunctionTranslate.cpp     2000/11/20 20:04:30     1.4
  @@ -139,7 +139,7 @@
        }
        else
        {
  -             return 
executionContext.getXObjectFactory().createString(XalanDOMString(theBuffer.begin(),
 theSize));
  +             return 
executionContext.getXObjectFactory().createString(theBuffer.begin(), theSize);
        }
   }
   
  
  
  
  1.14      +22 -0     xml-xalan/c/src/XPath/XObjectFactory.hpp
  
  Index: XObjectFactory.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactory.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XObjectFactory.hpp        2000/10/13 21:20:50     1.13
  +++ XObjectFactory.hpp        2000/11/20 20:04:30     1.14
  @@ -176,6 +176,28 @@
                        const XalanDOMString&   theValue) = 0;
   
        /**
  +      * Create a string XObject from a null-terminated array of characters.
  +      * 
  +      * @param theValue  a pointer to the array
  +      * @return pointer to new object
  +      */
  +     virtual XObject*
  +     createString(
  +                     const XalanDOMChar*             theValue) = 0;
  +
  +     /**
  +      * Create a string XObject from an array of characters.
  +      * 
  +      * @param theValue  a pointer to the array
  +      * @paran theLength the length of the array
  +      * @return pointer to new object
  +      */
  +     virtual XObject*
  +     createString(
  +                     const XalanDOMChar*             theValue,
  +                     unsigned int                    theLength) = 0;
  +
  +     /**
         * Create an "unknown" XObject from a string.
         * 
         * @param theValue  value used to create object  
  
  
  
  1.16      +35 -3     xml-xalan/c/src/XPath/XObjectFactoryDefault.cpp
  
  Index: XObjectFactoryDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactoryDefault.cpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XObjectFactoryDefault.cpp 2000/10/13 21:20:51     1.15
  +++ XObjectFactoryDefault.cpp 2000/11/20 20:04:30     1.16
  @@ -119,9 +119,10 @@
        {
        case XObject::eTypeBoolean:
        case XObject::eTypeNull:
  -     {               
  -             bStatus = true;
  -     }       
  +             {               
  +                     bStatus = true;
  +             }
  +
        case XObject::eTypeString:
                {
                        XString* const  theXString =
  @@ -134,6 +135,7 @@
                        bStatus = m_xstringAllocator.destroy(theXString);
                }
                break;
  +
        case  XObject::eTypeNumber:
                {
                        XNumber* const  theXNumber =
  @@ -146,6 +148,7 @@
                        bStatus = m_xnumberAllocator.destroy(theXNumber);
                }
                break;
  +
        case XObject::eTypeNodeSet:
                {
                        XNodeSet* const theXNodeSet =
  @@ -158,6 +161,7 @@
                        bStatus = m_xnodesetAllocator.destroy(theXNodeSet);
                }
                break;
  +
        case XObject::eTypeResultTreeFrag:      
                {
                        XResultTreeFrag* const  theXResultTreeFrag =    
  @@ -170,6 +174,7 @@
                        bStatus = 
m_xresultTreeFragAllocator.destroy(theXResultTreeFrag);
                }
                break;
  +
        default:
                {
                        const CollectionType::iterator  i =
  @@ -228,6 +233,7 @@
   #endif
   
                        break;
  +
                case  XObject::eTypeNumber:
                        theClone = m_xnumberAllocator.clone(
   #if defined(XALAN_OLD_STYLE_CASTS)
  @@ -237,6 +243,7 @@
   #endif
   
                        break;
  +
                case XObject::eTypeNodeSet:
                        theClone = m_xnodesetAllocator.clone(
   #if defined(XALAN_OLD_STYLE_CASTS)
  @@ -246,6 +253,7 @@
   #endif
   
                        break;
  +
                case XObject::eTypeResultTreeFrag:
                        theClone = m_xresultTreeFragAllocator.clone(
   #if defined(XALAN_OLD_STYLE_CASTS)
  @@ -255,6 +263,7 @@
   #endif
   
                        break;
  +
                default:
                        XObject* const  theClone = theXObject.clone();
   
  @@ -338,6 +347,29 @@
                        const XalanDOMString&   theValue)
   {
        XString* const  theXString = m_xstringAllocator.createString(theValue);
  +
  +     return theXString;
  +}
  +
  +
  +
  +XObject*
  +XObjectFactoryDefault::createString(
  +                     const XalanDOMChar*             theValue)
  +{
  +     XString* const  theXString = m_xstringAllocator.createString(theValue);
  +
  +     return theXString;
  +}
  +
  +
  +
  +XObject*
  +XObjectFactoryDefault::createString(
  +                     const XalanDOMChar*             theValue,
  +                     unsigned int                    theLength)
  +{
  +     XString* const  theXString = m_xstringAllocator.createString(theValue, 
theLength);
   
        return theXString;
   }
  
  
  
  1.15      +9 -0      xml-xalan/c/src/XPath/XObjectFactoryDefault.hpp
  
  Index: XObjectFactoryDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactoryDefault.hpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- XObjectFactoryDefault.hpp 2000/11/02 01:46:00     1.14
  +++ XObjectFactoryDefault.hpp 2000/11/20 20:04:31     1.15
  @@ -155,6 +155,15 @@
                        const XalanDOMString&   theValue);
   
        virtual XObject*
  +     createString(
  +                     const XalanDOMChar*             theValue);
  +
  +     virtual XObject*
  +     createString(
  +                     const XalanDOMChar*             theValue,
  +                     unsigned int                    theLength);
  +
  +     virtual XObject*
        createUnknown(
                        const XalanDOMString&   theValue);
   
  
  
  
  1.27      +34 -0     xml-xalan/c/src/XPath/XPathExecutionContext.hpp
  
  Index: XPathExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContext.hpp,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- XPathExecutionContext.hpp 2000/11/08 14:27:15     1.26
  +++ XPathExecutionContext.hpp 2000/11/20 20:04:31     1.27
  @@ -482,6 +482,40 @@
                MutableNodeRefList*             m_mutableNodeRefList;
        };
   
  +     virtual XalanDOMString&
  +     getCachedString() = 0;
  +
  +     virtual bool
  +     releaseCachedString(XalanDOMString&             theString) = 0;
  +
  +     class GetAndReleaseCachedString
  +     {
  +     public:
  +
  +             GetAndReleaseCachedString(XPathExecutionContext&        
theExecutionContext) :
  +                     m_executionContext(theExecutionContext),
  +                     m_string(&m_executionContext.getCachedString())
  +             {
  +             }
  +
  +             ~GetAndReleaseCachedString()
  +             {
  +                     m_executionContext.releaseCachedString(*m_string);
  +             }
  +
  +             XalanDOMString&
  +             get() const
  +             {
  +                     return *m_string;
  +             }
  +
  +     private:
  +
  +             XPathExecutionContext&  m_executionContext;
  +
  +             XalanDOMString* const   m_string;
  +     };
  +
        /**
         * Create a MutableNodeRefList with the appropriate context.
         *
  
  
  
  1.24      +33 -11    xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp
  
  Index: XPathExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XPathExecutionContextDefault.cpp  2000/11/08 17:03:15     1.23
  +++ XPathExecutionContextDefault.cpp  2000/11/20 20:04:31     1.24
  @@ -95,7 +95,8 @@
        m_prefixResolver(thePrefixResolver),
        m_throwFoundIndex(false),
        m_availableCachedNodeLists(),
  -     m_busyCachedNodeLists()
  +     m_busyCachedNodeLists(),
  +     m_stringCache()
   {
        m_availableCachedNodeLists.reserve(eMutableNodeRefListCacheMax);
   
  @@ -106,7 +107,16 @@
   
   XPathExecutionContextDefault::~XPathExecutionContextDefault()
   {
  +#if !defined(XALAN_NO_NAMESPACES)
  +     using std::for_each;
  +#endif
  +
        reset();
  +
  +     for_each(
  +             m_availableCachedNodeLists.begin(),
  +             m_availableCachedNodeLists.end(),
  +             DeleteFunctor<MutableNodeRefList>());
   }
   
   
  @@ -117,19 +127,15 @@
        m_xpathEnvSupport.reset();
        m_xpathSupport.reset();
        m_xobjectFactory.reset();
  -
  -     assert(m_busyCachedNodeLists.size() == 0);
   
  -#if !defined(XALAN_NO_NAMESPACES)
  -     using std::for_each;
  -#endif
  +     while (m_busyCachedNodeLists.size() != 0)
  +     {
  +             
m_availableCachedNodeLists.push_back(m_busyCachedNodeLists.back());
   
  -     for_each(
  -             m_availableCachedNodeLists.begin(),
  -             m_availableCachedNodeLists.end(),
  -             DeleteFunctor<MutableNodeRefList>());
  +             m_busyCachedNodeLists.pop_back();
  +     }
   
  -     m_availableCachedNodeLists.clear();
  +     m_stringCache.reset();
   }
   
   
  @@ -401,6 +407,22 @@
   XPathExecutionContextDefault::createMutableNodeRefList() const
   {
        return new MutableNodeRefList;
  +}
  +
  +
  +
  +XalanDOMString&
  +XPathExecutionContextDefault::getCachedString()
  +{
  +     return m_stringCache.get();
  +}
  +
  +
  +
  +bool
  +XPathExecutionContextDefault::releaseCachedString(XalanDOMString&    
theString)
  +{
  +     return m_stringCache.release(theString);
   }
   
   
  
  
  
  1.24      +23 -13    xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp
  
  Index: XPathExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XPathExecutionContextDefault.hpp  2000/11/08 17:03:19     1.23
  +++ XPathExecutionContextDefault.hpp  2000/11/20 20:04:31     1.24
  @@ -82,6 +82,10 @@
   
   
   
  +#include <PlatformSupport/XalanDOMStringCache.hpp>
  +
  +
  +
   #include <XPath/NodeRefList.hpp>
   
   
  @@ -218,7 +222,13 @@
        virtual MutableNodeRefList*
        createMutableNodeRefList() const;
   
  +     virtual XalanDOMString&
  +     getCachedString();
  +
        virtual bool
  +     releaseCachedString(XalanDOMString&             theString);
  +
  +     virtual bool
        getProcessNamespaces() const;
   
        virtual void
  @@ -318,34 +328,34 @@
        typedef std::vector<MutableNodeRefList*>        NodeRefListCacheType;
   #endif
   
  -
  -
   protected:
   
        enum { eMutableNodeRefListCacheMax = 50,
                   eCachedArgVectorDefaultSize = 10 };
  +
  +     XPathEnvSupport&                        m_xpathEnvSupport;
   
  -     XPathEnvSupport&                                m_xpathEnvSupport;
  +     XPathSupport&                           m_xpathSupport;
   
  -     XPathSupport&                                   m_xpathSupport;
  +     XObjectFactory&                         m_xobjectFactory;
   
  -     XObjectFactory&                                 m_xobjectFactory;
  +     XalanNode*                                      m_currentNode;
   
  -     XalanNode*                                              m_currentNode;
  +     const NodeRefListBase*          m_contextNodeList;
   
  -     const NodeRefListBase*                  m_contextNodeList;
  +     const PrefixResolver*           m_prefixResolver;
   
  -     const PrefixResolver*                   m_prefixResolver;
  +     bool                                            m_throwFoundIndex;
   
  -     bool                                                    
m_throwFoundIndex;
  +     XalanDOMString                          m_currentPattern;
   
  -     XalanDOMString                                  m_currentPattern;
  +     NodeRefListCacheType            m_availableCachedNodeLists;
   
  -     NodeRefListCacheType                    m_availableCachedNodeLists;
  +     NodeRefListCacheType            m_busyCachedNodeLists;
   
  -     NodeRefListCacheType                    m_busyCachedNodeLists;
  +     XalanDOMStringCache                     m_stringCache;
   
  -     static const NodeRefList                s_dummyList;
  +     static const NodeRefList        s_dummyList;
   };
   
   
  
  
  
  1.14      +22 -0     xml-xalan/c/src/XPath/XString.cpp
  
  Index: XString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XString.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XString.cpp       2000/09/19 14:56:44     1.13
  +++ XString.cpp       2000/11/20 20:04:31     1.14
  @@ -84,6 +84,28 @@
   
   
   
  +XString::XString(const XalanDOMChar* val) :
  +     XObject(eTypeString),
  +     m_value(val),
  +     m_cachedNumberValue(0.0),
  +     m_resultTreeFrag(0)
  +{
  +}
  +
  +
  +
  +XString::XString(
  +                     const XalanDOMChar*             val,
  +                     unsigned int                    len) :
  +     XObject(eTypeString),
  +     m_value(val, len),
  +     m_cachedNumberValue(0.0),
  +     m_resultTreeFrag(0)
  +{
  +}
  +
  +
  +
   XString::XString(const XString&      source) :
        XObject(source),
        m_value(source.m_value),
  
  
  
  1.14      +6 -0      xml-xalan/c/src/XPath/XString.hpp
  
  Index: XString.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XString.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XString.hpp       2000/11/02 01:46:04     1.13
  +++ XString.hpp       2000/11/20 20:04:32     1.14
  @@ -100,6 +100,12 @@
         */
        XString(const XalanDOMString&   val);
   
  +     XString(const XalanDOMChar*             val);
  +
  +     XString(
  +                     const XalanDOMChar*             val,
  +                     unsigned int                    len);
  +
        XString(const XString&  source);
   
        virtual
  
  
  
  1.2       +32 -0     xml-xalan/c/src/XPath/XStringAllocator.cpp
  
  Index: XStringAllocator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XStringAllocator.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XStringAllocator.cpp      2000/10/13 21:24:02     1.1
  +++ XStringAllocator.cpp      2000/11/20 20:04:32     1.2
  @@ -89,6 +89,38 @@
   
   
   XStringAllocator::string_type*
  +XStringAllocator::createString(const XalanDOMChar*   theString)
  +{
  +     string_type* const      theBlock = m_allocator.allocateBlock();
  +     assert(theBlock != 0);
  +
  +     string_type* const      theResult = new(theBlock) 
string_type(theString);
  +
  +     m_allocator.commitAllocation(theBlock);
  +
  +     return theResult;
  +}
  +
  +
  +
  +XStringAllocator::string_type*
  +XStringAllocator::createString(
  +                     const XalanDOMChar*             theString,
  +                     unsigned int                    theLength)
  +{
  +     string_type* const      theBlock = m_allocator.allocateBlock();
  +     assert(theBlock != 0);
  +
  +     string_type* const      theResult = new(theBlock) 
string_type(theString, theLength);
  +
  +     m_allocator.commitAllocation(theBlock);
  +
  +     return theResult;
  +}
  +
  +
  +
  +XStringAllocator::string_type*
   XStringAllocator::clone(const XString&       value)
   {
        string_type* const              theBlock = m_allocator.allocateBlock();
  
  
  
  1.2       +24 -1     xml-xalan/c/src/XPath/XStringAllocator.hpp
  
  Index: XStringAllocator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XStringAllocator.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XStringAllocator.hpp      2000/10/13 21:24:02     1.1
  +++ XStringAllocator.hpp      2000/11/20 20:04:32     1.2
  @@ -92,7 +92,7 @@
        ~XStringAllocator();
   
        /**
  -      * Create an XString object using allocator from a string.
  +      * Create an XString object from a string.
         * 
         * @param theString     source string
         *
  @@ -100,6 +100,29 @@
         */
        string_type*
        createString(const XalanDOMString&      theString);
  +
  +     /**
  +      * Create an XString object from a null-terminated array of characters.
  +      * 
  +      * @param theString     a pointer to the array
  +      *
  +      * @return a pointer to string
  +      */
  +     string_type*
  +     createString(const XalanDOMChar*        theString);
  +
  +     /**
  +      * Create an XString object from an array of characters.
  +      * 
  +      * @param theString     a pointer to the array
  +      * @param theLength     the length of the array.
  +      *
  +      * @return a pointer to string
  +      */
  +     string_type*
  +     createString(
  +                     const XalanDOMChar*             theString,
  +                     unsigned int                    theLength);
   
        /**
         * Clone an XString object.
  
  
  
  1.11      +4 -4      xml-xalan/c/src/XSLT/ElemAttribute.cpp
  
  Index: ElemAttribute.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttribute.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ElemAttribute.cpp 2000/11/02 01:46:19     1.10
  +++ ElemAttribute.cpp 2000/11/20 20:04:36     1.11
  @@ -263,17 +263,17 @@
                // If there was no namespace, or the namespace was resolved, 
process
                // the result attribute.
                if (indexOfNSSep == origAttrNameLength || 
!isEmpty(attrNameSpace))
  -             {  
  -                     XalanDOMString  val;
  +             {
  +                     StylesheetExecutionContext::GetAndReleaseCachedString   
theResult(executionContext);
   
                        childrenToString(
                                        executionContext,
                                        sourceTree,
                                        sourceNode,
                                        mode,
  -                                     val);
  +                                     theResult.get());
   
  -                     executionContext.addResultAttribute(attrName, val);
  +                     executionContext.addResultAttribute(attrName, 
theResult.get());
                }
        }
   }
  
  
  
  1.5       +8 -11     xml-xalan/c/src/XSLT/ElemComment.cpp
  
  Index: ElemComment.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemComment.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ElemComment.cpp   2000/11/02 01:46:20     1.4
  +++ ElemComment.cpp   2000/11/20 20:04:36     1.5
  @@ -116,19 +116,16 @@
   {
        ElemTemplateElement::execute(executionContext, sourceTree, sourceNode, 
mode);
   
  -    // Note the content model is:
  -    // <!ENTITY % instructions "
  -    // %char-instructions;
  -    // | xsl:processing-instruction
  -    // | xsl:comment
  -    // | xsl:element
  -    // | xsl:attribute
  -    // ">
  -    XalanDOMString   data;
  +     StylesheetExecutionContext::GetAndReleaseCachedString   
theResult(executionContext);
   
  -     childrenToString(executionContext, sourceTree, sourceNode, mode, data);
  +     childrenToString(
  +                     executionContext,
  +                     sourceTree,
  +                     sourceNode,
  +                     mode,
  +                     theResult.get());
   
  -    executionContext.comment(toCharArray(data));
  +    executionContext.comment(c_wstr(theResult.get()));
   }
   
   
  
  
  
  1.6       +9 -4      xml-xalan/c/src/XSLT/ElemMessage.cpp
  
  Index: ElemMessage.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemMessage.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ElemMessage.cpp   2000/11/02 01:46:24     1.5
  +++ ElemMessage.cpp   2000/11/20 20:04:36     1.6
  @@ -125,15 +125,20 @@
   {
        ElemTemplateElement::execute(executionContext, sourceTree, sourceNode, 
mode);
   
  -    XalanDOMString   data;
  +     StylesheetExecutionContext::GetAndReleaseCachedString   
theResult(executionContext);
   
  -     childrenToString(executionContext, sourceTree, sourceNode, mode, data);
  +     childrenToString(
  +                     executionContext,
  +                     sourceTree,
  +                     sourceNode,
  +                     mode,
  +                     theResult.get());
   
  -    executionContext.message(data, sourceNode, this);
  +    executionContext.message(theResult.get(), sourceNode, this);
   
        if (m_terminate == true)
        {
  -             throw ElemMessageTerminateException(data);
  +             throw ElemMessageTerminateException(theResult.get());
        }
   }
   
  
  
  
  1.6       +8 -3      xml-xalan/c/src/XSLT/ElemPI.cpp
  
  Index: ElemPI.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemPI.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ElemPI.cpp        2000/11/02 01:46:25     1.5
  +++ ElemPI.cpp        2000/11/20 20:04:37     1.6
  @@ -140,11 +140,16 @@
                error("processing-instruction name must be a valid NCName: " + 
piName);
        }
   
  -     XalanDOMString  data;
  +     StylesheetExecutionContext::GetAndReleaseCachedString   
theResult(executionContext);
   
  -     childrenToString(executionContext, sourceTree, sourceNode, mode, data);
  +     childrenToString(
  +                     executionContext,
  +                     sourceTree,
  +                     sourceNode,
  +                     mode,
  +                     theResult.get());
   
  -     executionContext.processingInstruction(toCharArray(piName), 
toCharArray(data));
  +     executionContext.processingInstruction(toCharArray(piName), 
toCharArray(theResult.get()));
   }
   
   
  
  
  
  1.39      +3 -2      xml-xalan/c/src/XSLT/ElemTemplateElement.cpp
  
  Index: ElemTemplateElement.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.cpp,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- ElemTemplateElement.cpp   2000/11/02 22:26:00     1.38
  +++ ElemTemplateElement.cpp   2000/11/20 20:04:37     1.39
  @@ -320,8 +320,9 @@
        // a string.
        DOMStringPrintWriter            thePrintWriter(result);
   
  -     // Create a FormatterToText.
  -     FormatterToText                         theFormatter(thePrintWriter);
  +     // Create a FormatterToText, and don't normalize CR/LF, since we dont' 
want
  +     // this text to be normalized.
  +     FormatterToText                         theFormatter(thePrintWriter, 
false);
   
        // Create an object to set and restore the execution state.
        StylesheetExecutionContext::OutputContextPushPop        
theOutputContextPushPop(
  
  
  
  1.14      +7 -5      xml-xalan/c/src/XSLT/ElemValueOf.cpp
  
  Index: ElemValueOf.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemValueOf.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ElemValueOf.cpp   2000/11/02 01:46:26     1.13
  +++ ElemValueOf.cpp   2000/11/20 20:04:37     1.14
  @@ -170,12 +170,12 @@
        if (m_isDot == true)
        {
   //           const XalanNode::NodeType       type = 
sourceNode->getNodeType();
  -
  +//
   //           if(type == XalanNode::COMMENT_NODE ||
   //         type == XalanNode::PROCESSING_INSTRUCTION_NODE)
   //           {
   //                   outputValue(executionContext, 
sourceNode->getNodeValue());
  -
  +//
   //                   if(0 != executionContext.getTraceListeners())
   //                   {
   //                           fireSelectionEvent(executionContext, 
sourceNode, theValue);
  @@ -183,13 +183,15 @@
   //           }
   //           else
                {
  -                     const XalanDOMString    theValue = 
DOMServices::getNodeData(*sourceNode);
  +                     StylesheetExecutionContext::GetAndReleaseCachedString   
theResult(executionContext);
  +
  +                     DOMServices::getNodeData(*sourceNode, theResult.get());
   
  -                     outputValue(executionContext, theValue);
  +                     outputValue(executionContext, theResult.get());
   
                        if(0 != executionContext.getTraceListeners())
                        {
  -                             fireSelectionEvent(executionContext, 
sourceNode, theValue);
  +                             fireSelectionEvent(executionContext, 
sourceNode, theResult.get());
                        }
                }
        }
  
  
  
  1.7       +33 -32    xml-xalan/c/src/XSLT/FunctionGenerateID.cpp
  
  Index: FunctionGenerateID.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionGenerateID.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FunctionGenerateID.cpp    2000/11/10 16:46:20     1.6
  +++ FunctionGenerateID.cpp    2000/11/20 20:04:37     1.7
  @@ -70,6 +70,10 @@
   
   
   
  +const XalanDOMString FunctionGenerateID::s_emptyString;
  +
  +
  +
   FunctionGenerateID::FunctionGenerateID() :
        Function(),
        m_prefix(XALAN_STATIC_UCODE_STRING("N")),
  @@ -85,8 +89,10 @@
   
   
   
  -const XalanDOMString
  -getSuffix(const XalanNode*   theNode)
  +void
  +getSuffix(
  +             const XalanNode*        theNode,
  +             XalanDOMString&         theResult)
   {
        const unsigned long             theIndex = theNode->getIndex();
   
  @@ -95,14 +101,14 @@
                // We're assuming here that each nodes has an implementation 
with a 
                // unique address that we can convert into a string
   #if defined(XALAN_OLD_STYLE_CASTS)
  -             return UnsignedLongToDOMString((unsigned long)theNode);
  +             UnsignedLongToDOMString((unsigned long)theNode, theResult);
   #else
  -             return UnsignedLongToDOMString(reinterpret_cast<unsigned 
long>(theNode));
  +             UnsignedLongToDOMString(reinterpret_cast<unsigned 
long>(theNode), theResult);
   #endif
        }
        else
        {
  -             return UnsignedLongToDOMString(theIndex);
  +             UnsignedLongToDOMString(theIndex, theResult);
        }
   }
   
  @@ -110,54 +116,50 @@
   
   XObject*
   FunctionGenerateID::execute(
  -             XPathExecutionContext&                  executionContext,
  -             XalanNode*                                              
context,                        
  -             const XObject*                                  arg1)
  +                     XPathExecutionContext&          executionContext,
  +                     XalanNode*                                      
context,                        
  +                     const XObject*                          arg1)
   {
        assert(arg1 != 0);      
   
        const NodeRefListBase&  theNodeList = arg1->nodeset();
   
  -     if (theNodeList.getLength() > 0)
  +     if (theNodeList.getLength() == 0)
        {
  -             context = theNodeList.item(0);
  +             return 
executionContext.getXObjectFactory().createString(s_emptyString);
        }
        else
  -     {       
  -             context = 0;
  +     {
  +             return execute(executionContext, theNodeList.item(0));
        }
  -
  -
  -     return execute(executionContext, context);
   }
   
   
   
   XObject*
   FunctionGenerateID::execute(
  -             XPathExecutionContext&                  executionContext,
  -             XalanNode*                                              context)
  +                     XPathExecutionContext&          executionContext,
  +                     XalanNode*                                      context)
   {
  +     if (context == 0)
  +     {
  +             executionContext.error("The function generate-id requires a 
non-null node!");
   
  -     XalanDOMString id;
  +             return 0;
  +     }
  +     else
  +     {
  +             XPathExecutionContext::GetAndReleaseCachedString        
theGuard(executionContext);
   
  -     //if (context == 0)
  -     //{
  -     //      executionContext.error("The generate-id function requires a 
non-null context node!");
  -     //}
  +             XalanDOMString&         theID = theGuard.get();
   
  -     if (context != 0)
  -     {
  -             const XalanDOMString    theSuffix = getSuffix(context);
  -             assert(length(theSuffix) != 0);
  +             getSuffix(context, theID);
  +             assert(length(theID) != 0);
   
  -             reserve(id, m_prefixLength + length(theSuffix) + 1);
  +             insert(theID, 0, m_prefix);
   
  -             id += m_prefix;
  -             id += theSuffix;
  +             return executionContext.getXObjectFactory().createString(theID);
        }
  -
  -     return executionContext.getXObjectFactory().createString(id);
   }
   
   
  @@ -180,4 +182,3 @@
        return XALAN_STATIC_UCODE_STRING(
                "The generate-id function takes zero or one arguments!");
   }
  -
  
  
  
  1.6       +5 -2      xml-xalan/c/src/XSLT/FunctionGenerateID.hpp
  
  Index: FunctionGenerateID.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionGenerateID.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FunctionGenerateID.hpp    2000/11/06 19:21:37     1.5
  +++ FunctionGenerateID.hpp    2000/11/20 20:04:37     1.6
  @@ -112,10 +112,13 @@
        bool
        operator==(const FunctionGenerateID&) const;
   
  -     const XalanDOMString    m_prefix;
  +     const XalanDOMString                    m_prefix;
   
  -     const unsigned int              m_prefixLength;
  +     const unsigned int                              m_prefixLength;
  +
  +     static const XalanDOMString             s_emptyString;
   };
  +
   
   
   #endif       // FUNCTIONGENERATEID_HEADER_GUARD_1357924680
  
  
  
  1.36      +6 -0      xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
  
  Index: StylesheetExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- StylesheetExecutionContext.hpp    2000/11/08 17:02:07     1.35
  +++ StylesheetExecutionContext.hpp    2000/11/20 20:04:37     1.36
  @@ -1424,6 +1424,12 @@
        virtual MutableNodeRefList*
        createMutableNodeRefList() const = 0;
   
  +     virtual XalanDOMString&
  +     getCachedString() = 0;
  +
  +     virtual bool
  +     releaseCachedString(XalanDOMString&             theString) = 0;
  +
        virtual bool
        getProcessNamespaces() const = 0;
   
  
  
  
  1.40      +113 -47   
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- StylesheetExecutionContextDefault.cpp     2000/11/08 17:02:11     1.39
  +++ StylesheetExecutionContextDefault.cpp     2000/11/20 20:04:37     1.40
  @@ -135,13 +135,12 @@
        m_printWriters(),
        m_outputStreams(),
        m_collationCompareFunctor(&s_defaultFunctor),
  -     m_liveVariablesStack(),
  +     m_liveVariablesStack(theXObjectFactory),
        m_variablesStack(),
        m_matchPatternCache(),
        m_keyTables(),
        m_keyDeclarationSet()
   {
  -     m_liveVariablesStack.reserve(eDefaultVariablesStackSize);
   }
   
   
  @@ -461,11 +460,9 @@
        const XObject* const    theVariable =
                xpath.execute(contextNode, resolver, *this);
   
  -     assert(m_liveVariablesStack.empty() == false);
  -
        // We'll want to return this variable after the current element frame
        // has finished executing, so save this off for later...
  -     m_liveVariablesStack.back().push_back(theVariable);
  +     m_liveVariablesStack.pushVariable(theVariable);
   
        return theVariable;
   }
  @@ -485,7 +482,7 @@
   
        // We'll want to return this variable after the current element frame
        // has finished executing, so save this off for later...
  -     m_liveVariablesStack.back().push_back(theVariable);
  +     m_liveVariablesStack.pushVariable(theVariable);
   
        return theVariable;
   }
  @@ -530,7 +527,7 @@
        {
                // We'll want to return this variable after the current element 
frame
                // has finished executing, so save this off for later...
  -             m_liveVariablesStack.back().push_back(var);
  +             m_liveVariablesStack.pushVariable(var);
        }
   }
   
  @@ -578,10 +575,8 @@
   StylesheetExecutionContextDefault::pushContextMarker()
   {
        m_variablesStack.pushContextMarker();
  -
  -     m_liveVariablesStack.resize(m_liveVariablesStack.size() + 1); 
//LiveVariablesStackType::value_type());
   
  -     m_liveVariablesStack.back().reserve(eDefaultVariablesCollectionSize);
  +     m_liveVariablesStack.pushContext();
   }
   
   
  @@ -591,7 +586,7 @@
   {
        m_variablesStack.popContextMarker();
   
  -     popLiveVariablesStack();
  +     m_liveVariablesStack.popContext();
   }
   
   
  @@ -721,7 +716,7 @@
   {
        m_variablesStack.pushElementFrame(elem);
   
  -     m_liveVariablesStack.resize(m_liveVariablesStack.size() + 1); 
//(LiveVariablesStackType::value_type());
  +     m_liveVariablesStack.pushContext();
   }
   
   
  @@ -731,7 +726,7 @@
   {
        m_variablesStack.popElementFrame(elem);
   
  -     popLiveVariablesStack();
  +     m_liveVariablesStack.popContext();
   }
   
   
  @@ -1312,7 +1307,7 @@
   
        m_outputStreams.clear();
   
  -     clearLiveVariablesStack();
  +     m_liveVariablesStack.clear();
   
        m_variablesStack.reset();
   
  @@ -1555,6 +1550,22 @@
   
   
   
  +XalanDOMString&
  +StylesheetExecutionContextDefault::getCachedString()
  +{
  +     return m_xpathExecutionContextDefault.getCachedString();
  +}
  +
  +
  +
  +bool
  +StylesheetExecutionContextDefault::releaseCachedString(XalanDOMString&       
theString)
  +{
  +     return m_xpathExecutionContextDefault.releaseCachedString(theString);
  +}
  +
  +
  +
   bool
   StylesheetExecutionContextDefault::getProcessNamespaces() const
   {
  @@ -1851,39 +1862,6 @@
   
   
   
  -void
  -StylesheetExecutionContextDefault::popLiveVariablesStack()
  -{
  -#if !defined(XALAN_NO_NAMESPACES)
  -     using std::for_each;
  -#endif
  -
  -     assert(m_liveVariablesStack.empty() == false);
  -
  -     // Clean up any XObjects we created...
  -     for_each(
  -                     m_liveVariablesStack.back().begin(),
  -                     m_liveVariablesStack.back().end(),
  -                     
XObjectFactory::DeleteXObjectFunctor(getXObjectFactory()));
  -
  -     // Pop the stack...
  -     m_liveVariablesStack.pop_back();
  -}
  -
  -
  -
  -void
  -StylesheetExecutionContextDefault::clearLiveVariablesStack()
  -{
  -     // Clean up the entire stack.
  -     while(m_liveVariablesStack.empty() == false)
  -     {
  -             popLiveVariablesStack();
  -     }
  -}
  -
  -
  -
   bool
   StylesheetExecutionContextDefault::isCached(const XPath*     theXPath)
   {
  @@ -1986,4 +1964,92 @@
   
        // Add the XPath with the current clock
        m_matchPatternCache.insert(XPathCacheMapType::value_type(pattern, 
XPathCacheEntry(theXPath, addClock)));
  +}
  +
  +
  +
  
+StylesheetExecutionContextDefault::LiveVariablesStack::LiveVariablesStack(XObjectFactory&
    theXObjectFactory) :
  +     m_xobjectFactory(theXObjectFactory),
  +     m_variablesStack(),
  +     m_createNewContextStack()
  +{
  +}
  +
  +
  +
  +StylesheetExecutionContextDefault::LiveVariablesStack::~LiveVariablesStack()
  +{
  +     clear();
  +}
  +
  +
  +
  +void
  +StylesheetExecutionContextDefault::LiveVariablesStack::pushVariable(const 
XObject*   theVariable)
  +{
  +     assert(m_createNewContextStack.size() != 0);
  +
  +     // Check to see if we need to create a new context and do so if 
necessary...
  +     if (m_createNewContextStack.back() == true)
  +     {
  +             m_variablesStack.resize(m_variablesStack.size() + 1);
  +
  +             
m_variablesStack.back().reserve(eDefaultVariablesCollectionSize);
  +
  +             m_createNewContextStack.back() = false;
  +     }
  +
  +     m_variablesStack.back().push_back(theVariable);
  +}
  +
  +
  +
  +void
  +StylesheetExecutionContextDefault::LiveVariablesStack::pushContext()
  +{
  +     if (m_createNewContextStack.size() == 0)
  +     {
  +             
m_createNewContextStack.reserve(eDefaultCreateNewContextStackSize);
  +     }
  +
  +     m_createNewContextStack.push_back(true);
  +}
  +
  +
  +
  +void
  +StylesheetExecutionContextDefault::LiveVariablesStack::popContext()
  +{
  +     assert(m_createNewContextStack.size() != 0);
  +
  +     if (m_createNewContextStack.back() == false)
  +     {
  +#if !defined(XALAN_NO_NAMESPACES)
  +             using std::for_each;
  +#endif
  +
  +             assert(m_variablesStack.empty() == false);
  +
  +             // Clean up any XObjects we created...
  +             for_each(
  +                             m_variablesStack.back().begin(),
  +                             m_variablesStack.back().end(),
  +                             
XObjectFactory::DeleteXObjectFunctor(m_xobjectFactory));
  +
  +             // Pop the stack...
  +             m_variablesStack.pop_back();
  +     }
  +
  +     m_createNewContextStack.pop_back();
  +}
  +
  +
  +
  +void
  +StylesheetExecutionContextDefault::LiveVariablesStack::clear()
  +{
  +     while(m_variablesStack.empty() == false)
  +     {
  +             popContext();
  +     }
   }
  
  
  
  1.37      +63 -16    
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- StylesheetExecutionContextDefault.hpp     2000/11/08 17:02:13     1.36
  +++ StylesheetExecutionContextDefault.hpp     2000/11/20 20:04:37     1.37
  @@ -107,8 +107,6 @@
                                less<XalanOutputStream*> >                      
        OutputStreamSetType;
        typedef set<const KeyDeclaration*,
                                less<const KeyDeclaration*> >                   
KeyDeclarationSetType;
  -     typedef vector<const XObject*>                                          
VariablesCollectionType;
  -     typedef vector<VariablesCollectionType>                         
LiveVariablesStackType;
        typedef pair<const XPath*, clock_t>                                     
XPathCacheEntry;
        typedef map<XalanDOMString,
                                XPathCacheEntry,
  @@ -119,8 +117,6 @@
        typedef std::set<PrintWriter*>                                          
PrintWriterSetType;
        typedef std::set<XalanOutputStream*>                            
OutputStreamSetType;
        typedef std::set<const KeyDeclaration*>                         
KeyDeclarationSetType;
  -     typedef std::vector<const XObject*>                                     
VariablesCollectionType;
  -     typedef std::vector<VariablesCollectionType>            
LiveVariablesStackType;
        typedef std::pair<const XPath*, clock_t>                        
XPathCacheEntry;
        typedef std::map<XalanDOMString, XPathCacheEntry>       
XPathCacheMapType;
   #endif
  @@ -667,6 +663,12 @@
        virtual MutableNodeRefList*
        createMutableNodeRefList() const;
   
  +     virtual XalanDOMString&
  +     getCachedString();
  +
  +     virtual bool
  +     releaseCachedString(XalanDOMString&             theString);
  +
        virtual bool
        getProcessNamespaces() const;
   
  @@ -775,19 +777,64 @@
                XSLTEngineImpl&         m_xsltProcessor;
        };
   
  -private:
  +     class LiveVariablesStack
  +     {
  +     public:
   
  -     /**
  -      * Pop the top entry from the live variables.
  -      */
  -     void
  -     popLiveVariablesStack();
  +#if defined(XALAN_NO_NAMESPACES)
  +                     typedef vector<bool>                                    
                BoolVectorType;
  +                     typedef vector<const XObject*>                          
        VariablesCollectionType;
  +                     typedef deque<VariablesCollectionType>                  
LiveVariablesStackType;
  +#else
  +                     typedef std::vector<bool>                               
                BoolVectorType;
  +                     typedef std::vector<const XObject*>                     
        VariablesCollectionType;
  +                     typedef std::deque<VariablesCollectionType>             
LiveVariablesStackType;
  +#endif
   
  -     /**
  -      * Clear out the entire stack of live variables.
  -      */
  -     void
  -     clearLiveVariablesStack();
  +             LiveVariablesStack(XObjectFactory&      theXObjectFactory);
  +
  +             ~LiveVariablesStack();
  +
  +             void
  +             pushVariable(const XObject*             theVariable);
  +
  +             void
  +             pushContext();
  +
  +             void
  +             popContext();
  +
  +             void
  +             clear();
  +
  +             bool
  +             empty() const
  +             {
  +                     return m_createNewContextStack.empty();
  +             }
  +
  +     private:
  +
  +             // not implemented
  +             LiveVariablesStack(const LiveVariablesStack&);
  +
  +             bool
  +             operator==(const LiveVariablesStack&) const;
  +
  +             LiveVariablesStack&
  +             operator=(const LiveVariablesStack&);
  +
  +             enum { eDefaultCreateNewContextStackSize = 100, 
eDefaultVariablesCollectionSize = 10 };
  +
  +
  +             XObjectFactory&                 m_xobjectFactory;
  +
  +             LiveVariablesStackType  m_variablesStack;
  +
  +             BoolVectorType                  m_createNewContextStack;
  +     };
  +
  +private:
   
        /**
         * Determine if the XPath is one that we have cached.
  @@ -842,7 +889,7 @@
   
        const CollationCompareFunctor*          m_collationCompareFunctor;
   
  -     LiveVariablesStackType                          m_liveVariablesStack;
  +     LiveVariablesStack                                      
m_liveVariablesStack;
   
        /**
         * Holds all information about variables during execution.
  
  
  
  1.30      +15 -0     xml-xalan/c/src/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- StylesheetRoot.cpp        2000/11/02 22:26:02     1.29
  +++ StylesheetRoot.cpp        2000/11/20 20:04:37     1.30
  @@ -111,6 +111,13 @@
   
   
   
  +//#define XALAN_VQ_SPECIAL_TRACE
  +#if defined(XALAN_VQ_SPECIAL_TRACE)
  +#include "d:/Rational/Quantify/pure.h"
  +#endif
  +
  +
  +
   /**
    * Constructor for a Stylesheet needs a Document.
    * @exception XSLProcessorException thrown if the active ProblemListener and
  @@ -204,6 +211,10 @@
                throw SAXException("StylesheetRoot.process error");
        }
   
  +#if defined(XALAN_VQ_SPECIAL_TRACE)
  +     QuantifyStartRecordingData();
  +#endif
  +
        executionContext.startDocument();
   
        // Output the action of the found root rule.  All processing
  @@ -211,6 +222,10 @@
        rootRule->execute(executionContext, sourceTree, sourceTree, QName());
   
        executionContext.endDocument();
  +
  +#if defined(XALAN_VQ_SPECIAL_TRACE)
  +     QuantifyStopRecordingData();
  +#endif
   
        // Reset the top-level params for the next round.
        executionContext.clearTopLevelParams();
  
  
  
  1.69      +17 -45    xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
  
  Index: XSLTEngineImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- XSLTEngineImpl.cpp        2000/11/03 19:26:20     1.68
  +++ XSLTEngineImpl.cpp        2000/11/20 20:04:38     1.69
  @@ -167,8 +167,6 @@
        m_resultNameSpacePrefix(),
        m_resultNameSpaceURL(),
        m_currentNode(),
  -     m_resultNameSpaces(),
  -     m_emptyNamespace(),
        m_xpathFactory(xpathFactory),
        m_xobjectFactory(xobjectFactory),
        m_xpathProcessor(new XPathProcessorImpl),
  @@ -189,9 +187,10 @@
        m_xpathEnvSupport(xpathEnvSupport),
        m_domSupport(domSupport),
        m_executionContext(0),
  -     m_outputContextStack(1),
  -     m_outputContextStackPosition(m_outputContextStack.begin())
  +     m_outputContextStack(),
  +     m_resultNamespacesStack()
   {
  +     m_outputContextStack.pushContext();
   }
   
   
  @@ -206,15 +205,16 @@
        m_resultTreeFactory = 0;
        m_currentNode = 0;
   
  -     m_outputContextStack.clear();
  +     m_outputContextStack.reset();
   
  -     m_outputContextStack.push_back(OutputContextStackType::value_type());
  -     m_outputContextStackPosition = m_outputContextStack.begin();
  +     m_outputContextStack.pushContext();
   
        m_xpathSupport.reset();
        m_xpathEnvSupport.reset();
        m_xpathFactory.reset();
        m_xobjectFactory.reset();
  +
  +     m_resultNamespacesStack.clear();
   }
   
   
  @@ -1409,6 +1409,8 @@
        assert(getFormatterListener() != 0);
        assert(m_executionContext != 0);
   
  +     m_resultNamespacesStack.pushContext();
  +
        if (getHasPendingStartDocument() == false)
        {
                setHasPendingStartDocument(true);
  @@ -1452,6 +1454,8 @@
   
                fireGenerateEvent(ge);
        }
  +
  +     m_resultNamespacesStack.popContext();
   }
   
   
  @@ -1461,30 +1465,7 @@
                        const XalanDOMString&   prefix, 
                const XalanDOMString&   namespaceVal)
   {
  -     const NameSpace         ns(prefix, namespaceVal);
  -
  -     if (m_resultNameSpaces.size() == 0)
  -     {
  -             NamespaceVectorType             nsVector(1, ns);
  -
  -             m_resultNameSpaces.push_back(nsVector);
  -     }
  -     else
  -     {
  -             NamespaceVectorType&    nsOnStack = m_resultNameSpaces.back();
  -
  -             // If the last vector contains only an empty namespace, replace 
it with a
  -             // new vector containing only this namespace
  -             if(isEmpty(nsOnStack.front().getURI()))
  -             {
  -                     nsOnStack.front() = ns;
  -             }
  -             // Otherwise, add the namespace at the end of the last vector
  -             else
  -             {
  -                     nsOnStack.push_back(ns);
  -             }
  -     }
  +     m_resultNamespacesStack.addDeclaration(prefix, namespaceVal);
   }
   
   
  @@ -1631,11 +1612,8 @@
   
        flushPending();
   
  -     // Push a new container on the stack.
  -     m_resultNameSpaces.resize(m_resultNameSpaces.size() + 1);
  +     m_resultNamespacesStack.pushContext();
   
  -     m_resultNameSpaces.back().resize(1);
  -
        setPendingElementName(name);
   
        setMustFlushPendingStartDocument(true);
  @@ -1669,12 +1647,8 @@
                        atts.getType(i),
                        atts.getValue(i));
        }
  -
  -     // Push a new container on the stack, then resize it
  -     // to contain one empty namespaces vector.
  -     m_resultNameSpaces.resize(m_resultNameSpaces.size() + 1);
   
  -     m_resultNameSpaces.back().resize(1);
  +     m_resultNamespacesStack.pushContext();
   
        setPendingElementName(name);
   }
  @@ -1698,7 +1672,7 @@
                fireGenerateEvent(ge);
        }
   
  -     m_resultNameSpaces.pop_back();
  +     m_resultNamespacesStack.popContext();
   
        const Stylesheet::QNameVectorType&      cdataElems =
                m_stylesheetRoot->getCDATASectionElems();
  @@ -2303,8 +2277,7 @@
   const XalanDOMString&
   XSLTEngineImpl::getResultNamespaceForPrefix(const XalanDOMString&    prefix) 
const
   {
  -     // Search vector from first element back
  -     return QName::getNamespaceForPrefix(m_resultNameSpaces, prefix, false);
  +     return m_resultNamespacesStack.getNamespaceForPrefix(prefix);
   }
     
   
  @@ -2312,8 +2285,7 @@
   const XalanDOMString&
   XSLTEngineImpl::getResultPrefixForNamespace(const XalanDOMString&    
theNamespace) const
   {
  -     // Search vector from first element back
  -     return QName::getPrefixForNamespace(m_resultNameSpaces, theNamespace, 
false);
  +     return m_resultNamespacesStack.getPrefixForNamespace(theNamespace);
   }
   
   
  
  
  
  1.52      +25 -74    xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp
  
  Index: XSLTEngineImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- XSLTEngineImpl.hpp        2000/11/02 22:26:03     1.51
  +++ XSLTEngineImpl.hpp        2000/11/20 20:04:38     1.52
  @@ -73,7 +73,6 @@
   // Standard library headers
   #include <cassert>
   #include <ctime>
  -#include <deque>
   #include <map>
   #include <set>
   
  @@ -83,7 +82,6 @@
   
   
   
  -// XSL header files.
   #include <XalanDOM/XalanDOMString.hpp>
   
   
  @@ -109,7 +107,9 @@
   
   
   #include "KeyDeclaration.hpp"
  +#include "OutputContextStack.hpp"
   #include "ProblemListenerDefault.hpp"
  +#include "ResultNamespacesStack.hpp"
   #include "StylesheetExecutionContext.hpp"
   #include "XSLTProcessorException.hpp"
   
  @@ -153,35 +153,6 @@
   {
   public:
   
  -     typedef QName::NamespaceVectorType              NamespaceVectorType;
  -     typedef QName::NamespacesStackType              NamespacesStackType;
  -
  -     struct OutputContext
  -     {
  -             OutputContext(FormatterListener*        theListener = 0) :
  -                     m_flistener(theListener),
  -                     m_pendingAttributes(),
  -                     m_pendingElementName(),
  -                     m_hasPendingStartDocument(false),
  -                     m_mustFlushPendingStartDocument(false)
  -             {
  -             }
  -
  -             ~OutputContext()
  -             {
  -             }
  -
  -             FormatterListener*      m_flistener;
  -
  -             AttributeListImpl       m_pendingAttributes;
  -
  -             XalanDOMString          m_pendingElementName;
  -
  -             bool                            m_hasPendingStartDocument;
  -
  -             bool                            m_mustFlushPendingStartDocument;
  -     };
  -
   #if defined(XALAN_NO_NAMESPACES)
        typedef map<XalanDOMString,
                                int,
  @@ -195,7 +166,6 @@
        typedef vector<const Locator*>                  LocatorStack;
        typedef vector<TraceListener*>                  TraceListenerVectorType;
        typedef vector<bool>                                    BoolVectorType;
  -     typedef deque<OutputContext>                    OutputContextStackType;
   #else
        typedef std::map<XalanDOMString, int>           AttributeKeysMapType;
        typedef std::map<XalanDOMString, int>           ElementKeysMapType;
  @@ -203,7 +173,6 @@
        typedef std::vector<const Locator*>                     LocatorStack;
        typedef std::vector<TraceListener*>                     
TraceListenerVectorType;
        typedef std::vector<bool>                                       
BoolVectorType;
  -     typedef std::deque<OutputContext>                       
OutputContextStackType;
   #endif
   
        typedef XalanAutoPtr<XPathProcessor>                            
XPathProcessorPtrType;
  @@ -1108,11 +1077,7 @@
        void
        pushOutputContext(FormatterListener*    theListener)
        {
  -             m_outputContextStack.resize(m_outputContextStack.size() + 1);
  -
  -             ++m_outputContextStackPosition;
  -
  -             (*m_outputContextStackPosition).m_flistener = theListener;
  +             m_outputContextStack.pushContext(theListener);
        }
   
        /*
  @@ -1121,11 +1086,7 @@
        void
        popOutputContext()
        {
  -             assert(m_outputContextStack.empty() == false);
  -
  -             m_outputContextStack.pop_back();
  -
  -             m_outputContextStackPosition--;
  +             m_outputContextStack.popContext();
        }
   
        /*
  @@ -1331,7 +1292,7 @@
        const AttributeListImpl&
        getPendingAttributesImpl() const
        {
  -             return (*m_outputContextStackPosition).m_pendingAttributes;
  +             return m_outputContextStack.getPendingAttributes();
        }
   
        /**
  @@ -1342,7 +1303,7 @@
        AttributeListImpl&
        getPendingAttributesImpl()
        {
  -             return (*m_outputContextStackPosition).m_pendingAttributes;
  +             return m_outputContextStack.getPendingAttributes();
        }
   
        /**
  @@ -1364,7 +1325,7 @@
        const XalanDOMString&
        getPendingElementNameImpl() const
        {
  -             return (*m_outputContextStackPosition).m_pendingElementName;
  +             return m_outputContextStack.getPendingElementName();
        }
   
        /**
  @@ -1375,7 +1336,7 @@
        XalanDOMString&
        getPendingElementNameImpl()
        {
  -             return (*m_outputContextStackPosition).m_pendingElementName;
  +             return m_outputContextStack.getPendingElementName();
        }
   
        /**
  @@ -1386,7 +1347,7 @@
        void
        setPendingElementNameImpl(const XalanDOMString&         elementName)
        {
  -             (*m_outputContextStackPosition).m_pendingElementName = 
elementName;
  +             m_outputContextStack.getPendingElementName() = elementName;
        }
   
        /**
  @@ -1399,7 +1360,7 @@
        {
                assert(elementName != 0);
   
  -             (*m_outputContextStackPosition).m_pendingElementName = 
elementName;
  +             m_outputContextStack.getPendingElementName() = elementName;
        }
   
        /*
  @@ -1409,7 +1370,7 @@
        bool
        getHasPendingStartDocumentImpl() const
        {
  -             return 
(*m_outputContextStackPosition).m_hasPendingStartDocument;
  +             return m_outputContextStack.getHasPendingStartDocument();
        }
   
        /*
  @@ -1417,9 +1378,9 @@
         * @param the new value
         */
        void
  -     setHasPendingStartDocumentImpl(bool     b)
  +     setHasPendingStartDocumentImpl(bool             b)
        {
  -             (*m_outputContextStackPosition).m_hasPendingStartDocument = b;
  +             m_outputContextStack.getHasPendingStartDocument() = b;
        }
   
        /*
  @@ -1429,7 +1390,7 @@
        bool
        getMustFlushPendingStartDocumentImpl() const
        {
  -             return 
(*m_outputContextStackPosition).m_mustFlushPendingStartDocument;
  +             return m_outputContextStack.getMustFlushPendingStartDocument();
        }
   
        /*
  @@ -1439,19 +1400,19 @@
        void
        setMustFlushPendingStartDocumentImpl(bool       b)
        {
  -             (*m_outputContextStackPosition).m_mustFlushPendingStartDocument 
= b;
  +             m_outputContextStack.getMustFlushPendingStartDocument() = b;
        }
   
        FormatterListener*
        getFormatterListenerImpl() const
        {
  -             return (*m_outputContextStackPosition).m_flistener;
  +             return m_outputContextStack.getFormatterListener();
        }
   
        void
        setFormatterListenerImpl(FormatterListener*             flistener)
        {
  -             (*m_outputContextStackPosition).m_flistener = flistener;
  +             m_outputContextStack.getFormatterListener() = flistener;
        }
   
        /**
  @@ -1514,23 +1475,11 @@
                        const XalanElement&             templateChild,
                        AttributeListImpl&              attList);
   
  -     /**
  -      * A stack to keep track of the result tree namespaces.
  -      */
  -     NamespacesStackType m_resultNameSpaces;
  -
  -     /**
  -      * This is pushed on the m_resultNameSpaces stack until a 
  -      * xmlns attribute is found.  It's special because it has
  -      * and empty prefix and uri field.
  -      */
  -     NameSpace                       m_emptyNamespace;
  -     
        // Factory for creating xpaths.
  -     XPathFactory&           m_xpathFactory;
  +     XPathFactory&                   m_xpathFactory;
   
        // Factory for creating xobjects
  -     XObjectFactory&         m_xobjectFactory;
  +     XObjectFactory&                 m_xobjectFactory;
   
        // The query/pattern-matcher object.
        XPathProcessorPtrType   m_xpathProcessor;
  @@ -1540,7 +1489,7 @@
         * cdata instead of escaped text.
         * ## Optimization: use array stack instead of object stack.
         */
  -     BoolVectorType  m_cdataStack;
  +     BoolVectorType                  m_cdataStack;
   
   private:
   
  @@ -1746,13 +1695,15 @@
         */
        StylesheetExecutionContext*             m_executionContext;
   
  -
        /*
         * Stack of current output contexts...
         */
  -     OutputContextStackType                          m_outputContextStack;
  +     OutputContextStack                              m_outputContextStack;
   
  -     OutputContextStackType::iterator        m_outputContextStackPosition;
  +     /*
  +      * Stack of current result namespaces...
  +      */
  +     ResultNamespacesStack                   m_resultNamespacesStack;
   
        static void
        installFunctions();
  
  
  

Reply via email to