dbertoni    00/07/21 12:50:07

  Modified:    c/src/XPath MutableNodeRefList.cpp MutableNodeRefList.hpp
                        NodeRefList.cpp NodeRefList.hpp ResultTreeFrag.hpp
                        XNodeSet.hpp XNull.hpp XPath.cpp
                        XPathEnvSupport.hpp XPathEnvSupportDefault.cpp
                        XPathEnvSupportDefault.hpp
                        XPathExecutionContextDefault.cpp
                        XPathExpression.cpp XResultTreeFrag.hpp XString.cpp
  Log:
  Performance tuning work.
  
  Revision  Changes    Path
  1.12      +3 -3      xml-xalan/c/src/XPath/MutableNodeRefList.cpp
  
  Index: MutableNodeRefList.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/MutableNodeRefList.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MutableNodeRefList.cpp    2000/07/07 22:53:08     1.11
  +++ MutableNodeRefList.cpp    2000/07/21 19:50:02     1.12
  @@ -185,7 +185,7 @@
        {
                ensureAllocation();
   
  -             m_nodeList.insert(&m_nodeList[pos], n);
  +             m_nodeList.insert(m_nodeList.begin() + pos, n);
        }
   }
   
  @@ -216,7 +216,7 @@
   {
        assert(pos < getLength());
   
  -     m_nodeList.erase(&m_nodeList[pos]);
  +     m_nodeList.erase(m_nodeList.begin() + pos);
   }
   
   
  @@ -253,7 +253,7 @@
        // more space than necessary, but it's a small price to
        // pay for the increased speed.  We can always shrink by
        // swapping if we have way to much space.
  -     m_nodeList.reserve(getLength() + theLength);
  +     ensureAllocation(getLength() + theLength);
   
        for (unsigned int i = 0; i < theLength; i++)
        {
  
  
  
  1.8       +0 -23     xml-xalan/c/src/XPath/MutableNodeRefList.hpp
  
  Index: MutableNodeRefList.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/MutableNodeRefList.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MutableNodeRefList.hpp    2000/07/07 22:53:08     1.7
  +++ MutableNodeRefList.hpp    2000/07/21 19:50:02     1.8
  @@ -218,29 +218,6 @@
        virtual XPathSupport*
        getSupport() const;
   
  -protected:
  -
  -     // Default vector allocation size.  It seems high, but
  -     // it's really worth it...
  -     enum
  -     {
  -             eDefaultVectorSize = 1000
  -     };
  -
  -     /**
  -      * Ensure that an allocation is either the default allocation
  -      * amount, or the amount specified in the parameter, whichever
  -      * is larger.
  -      *
  -      * @param theSize The requested size.
  -      */
  -     void
  -     ensureAllocation(NodeListVectorType::size_type  theSize = 0)
  -     {
  -             m_nodeList.reserve(eDefaultVectorSize > theSize ? 
eDefaultVectorSize : theSize);
  -     }
  -
  -
   private:
   
        XPathSupport*   m_support;
  
  
  
  1.7       +1 -1      xml-xalan/c/src/XPath/NodeRefList.cpp
  
  Index: NodeRefList.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/NodeRefList.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- NodeRefList.cpp   2000/05/29 22:22:09     1.6
  +++ NodeRefList.cpp   2000/07/21 19:50:02     1.7
  @@ -108,7 +108,7 @@
   
                const unsigned int      theLength = theRHS.getLength();
   
  -             m_nodeList.reserve(theLength);
  +             ensureAllocation(theLength);
   
                for(unsigned int i = 0; i < theLength; i++)
                {
  
  
  
  1.8       +21 -0     xml-xalan/c/src/XPath/NodeRefList.hpp
  
  Index: NodeRefList.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/NodeRefList.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NodeRefList.hpp   2000/05/29 22:22:09     1.7
  +++ NodeRefList.hpp   2000/07/21 19:50:02     1.8
  @@ -64,6 +64,7 @@
   
   
   
  +#include <deque>
   #include <vector>
   
   
  @@ -128,11 +129,31 @@
   
   protected:
   
  +     // Default vector allocation size.  It seems high, but
  +     // it's really worth it...
  +     enum
  +     {
  +             eDefaultVectorSize = 100
  +     };
  +
   #if defined(XALAN_NO_NAMESPACES)
        typedef vector<XalanNode*>                      NodeListVectorType;
   #else
        typedef std::vector<XalanNode*>         NodeListVectorType;
   #endif
  +
  +     /**
  +      * Ensure that an allocation is either the default allocation
  +      * amount, or the amount specified in the parameter, whichever
  +      * is larger.
  +      *
  +      * @param theSize The requested size.
  +      */
  +     void
  +     ensureAllocation(NodeListVectorType::size_type  theSize = 0)
  +     {
  +             m_nodeList.reserve(eDefaultVectorSize > theSize ? 
eDefaultVectorSize : theSize);
  +     }
   
        NodeListVectorType      m_nodeList;
   };
  
  
  
  1.8       +5 -16     xml-xalan/c/src/XPath/ResultTreeFrag.hpp
  
  Index: ResultTreeFrag.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/ResultTreeFrag.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ResultTreeFrag.hpp        2000/04/20 16:29:20     1.7
  +++ ResultTreeFrag.hpp        2000/07/21 19:50:02     1.8
  @@ -99,28 +99,14 @@
         * Construct a result tree fragment object from another.
         * 
         * @param theSource source to copy
  -      * @param deepClone true if subobjects should be copied, default true
  +      * @param deepClone true if subobjects should be copied, default is 
false
         */
        ResultTreeFrag(const ResultTreeFrag&    theSource,
  -                                bool                                         
deepClone = true);
  +                                bool                                         
deepClone = false);
   
        virtual
        ~ResultTreeFrag();
   
  -     ResultTreeFrag&
  -     operator=(const ResultTreeFrag&         theRHS)
  -     {
  -             if (&theRHS != this)
  -             {
  -                     ResultTreeFragBase::operator==(theRHS);
  -
  -                     m_document = theRHS.m_document;
  -                     m_children = m_children;
  -             }
  -
  -             return *this;
  -     }
  -
   
        // These interfaces are inherited from XalanDocumentFragment...
        virtual XalanDOMString
  @@ -216,6 +202,9 @@
   private:
   
        // Not defined
  +     ResultTreeFrag&
  +     operator=(const ResultTreeFrag&         theRHS);
  +
        bool
        operator==(const ResultTreeFrag&        theRHS) const;
   
  
  
  
  1.9       +1 -1      xml-xalan/c/src/XPath/XNodeSet.hpp
  
  Index: XNodeSet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XNodeSet.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XNodeSet.hpp      2000/07/13 22:47:14     1.8
  +++ XNodeSet.hpp      2000/07/21 19:50:02     1.9
  @@ -137,7 +137,7 @@
         */
        XNodeSet(
                        const XNodeSet&         source,
  -                     bool                            deepClone = true);
  +                     bool                            deepClone = false);
   
        virtual
        ~XNodeSet();
  
  
  
  1.7       +1 -1      xml-xalan/c/src/XPath/XNull.hpp
  
  Index: XNull.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XNull.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XNull.hpp 2000/07/13 22:47:15     1.6
  +++ XNull.hpp 2000/07/21 19:50:02     1.7
  @@ -107,7 +107,7 @@
         */
        XNull(
                        const XNull&    source,
  -                     bool                    deepClone = true);
  +                     bool                    deepClone = false);
   
        virtual
        ~XNull();
  
  
  
  1.21      +10 -10    xml-xalan/c/src/XPath/XPath.cpp
  
  Index: XPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- XPath.cpp 2000/07/12 21:46:51     1.20
  +++ XPath.cpp 2000/07/21 19:50:03     1.21
  @@ -1069,7 +1069,7 @@
        assert(expr1.get() != 0);
   
        // Try to optimize when the result of the execution is
  -     // already a string.
  +     // already a boolean.
        if (expr1->getType() == XObject::eTypeBoolean)
        {
                return expr1.release();
  @@ -1094,7 +1094,7 @@
        assert(expr1.get() != 0);
   
        // Try to optimize when the result of the execution is
  -     // already a string.
  +     // already a number.
        if (expr1->getType() == XObject::eTypeNumber)
        {
                return expr1.release();
  @@ -1156,7 +1156,10 @@
        assert(m_expression.m_opMap.size() > static_cast<unsigned>(opPos + 2));
        assert(m_expression.m_tokenQueue.size() > 
static_cast<unsigned>(m_expression.m_opMap[opPos + 2]));
   
  -     return 
executionContext.getXObjectFactory().createString(m_expression.m_tokenQueue[m_expression.m_opMap[opPos
 + 2]]->str());
  +     XObject* const  theToken = 
m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
  +     assert(theToken != 0 && theToken->getType() == XObject::eTypeString);
  +
  +     return executionContext.getXObjectFactory().clone(*theToken);
   }
   
   
  @@ -1195,12 +1198,6 @@
                                                            varName->str(),
                                                          context);
        }
  -     else
  -     {
  -             // Always clone the result of getting a variable, since it 
doesn't
  -             // necessarily belong to our context.
  -             result = executionContext.getXObjectFactory().clone(*result);
  -     }
   
        return result;
   }
  @@ -1226,8 +1223,11 @@
   {
        assert(m_expression.m_opMap.size() > static_cast<unsigned>(opPos + 2));
        assert(m_expression.m_tokenQueue.size() > 
static_cast<unsigned>(m_expression.m_opMap[opPos + 2]));
  +
  +     XObject* const  theToken = 
m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
  +     assert(theToken != 0 && theToken->getType() == XObject::eTypeNumber);
   
  -     return 
executionContext.getXObjectFactory().createNumber(m_expression.m_tokenQueue[m_expression.m_opMap[opPos
 + 2]]->num());
  +     return executionContext.getXObjectFactory().clone(*theToken);
   }
     
   
  
  
  
  1.10      +0 -12     xml-xalan/c/src/XPath/XPathEnvSupport.hpp
  
  Index: XPathEnvSupport.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEnvSupport.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XPathEnvSupport.hpp       2000/05/24 19:36:04     1.9
  +++ XPathEnvSupport.hpp       2000/07/21 19:50:03     1.10
  @@ -133,18 +133,6 @@
                        XPathExecutionContext&  executionContext) const = 0;
   
        /**
  -      * Given a name, locate a variable in the current context, and return 
  -      * a pointer to the object.
  -      *
  -      * @param theName name of variable
  -      * @return pointer to an XObject if the variable was found, 0 if it was 
not
  -      */
  -     virtual XObject*
  -     getVariable(
  -                     XObjectFactory&         factory,
  -                     const QName&            name) const = 0;
  -
  -     /**
         * Provides support for XML parsing service.
         *
         * @param urlString location of the XML
  
  
  
  1.13      +1 -14     xml-xalan/c/src/XPath/XPathEnvSupportDefault.cpp
  
  Index: XPathEnvSupportDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEnvSupportDefault.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XPathEnvSupportDefault.cpp        2000/05/26 19:20:41     1.12
  +++ XPathEnvSupportDefault.cpp        2000/07/21 19:50:03     1.13
  @@ -71,7 +71,6 @@
   
   
   
  -#include "QName.hpp"
   #include "SimpleNodeLocator.hpp"
   #include "XObject.hpp"
   #include "XObjectFactory.hpp"
  @@ -229,17 +228,6 @@
   
   
   
  -XObject*
  -XPathEnvSupportDefault::getVariable(
  -                     XObjectFactory&         xobjectFactory,
  -                     const QName&            name) const
  -
  -{
  -     return xobjectFactory.createUnknown(name.getLocalPart());
  -}
  -
  -
  -
   XalanDocument*
   XPathEnvSupportDefault::parseXML(
                        const XalanDOMString&   /* urlString */,
  @@ -437,8 +425,7 @@
                                        0,
                                        argVec);
        }
  -
  -     if (theResult == 0)
  +     else
        {
                XalanDOMString  theFunctionName;
   
  
  
  
  1.11      +0 -5      xml-xalan/c/src/XPath/XPathEnvSupportDefault.hpp
  
  Index: XPathEnvSupportDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEnvSupportDefault.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XPathEnvSupportDefault.hpp        2000/05/24 19:36:04     1.10
  +++ XPathEnvSupportDefault.hpp        2000/07/21 19:50:03     1.11
  @@ -153,11 +153,6 @@
                        const PrefixResolver&   resolver,
                        XPathExecutionContext&  executionContext) const;
   
  -     virtual XObject*
  -     getVariable(
  -                     XObjectFactory&         factory,
  -                     const QName&            name) const;
  -
        virtual XalanDocument*
        parseXML(
                        const XalanDOMString&   urlString,
  
  
  
  1.13      +3 -1      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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XPathExecutionContextDefault.cpp  2000/07/14 16:57:13     1.12
  +++ XPathExecutionContextDefault.cpp  2000/07/21 19:50:03     1.13
  @@ -64,7 +64,9 @@
   
   #include "ElementPrefixResolverProxy.hpp"
   #include "FoundIndex.hpp"
  +#include "XObjectFactory.hpp"
   #include "PrefixResolver.hpp"
  +#include "QName.hpp"
   #include "XPathEnvSupport.hpp"
   #include "XPathSupport.hpp"
   
  @@ -352,7 +354,7 @@
   XObject*
   XPathExecutionContextDefault::getVariable(const QName&       name) const
   {
  -     return m_xpathEnvSupport.getVariable(m_xobjectFactory, name); 
  +     return m_xobjectFactory.createUnknown(name.getLocalPart());
   }
   
   
  
  
  
  1.10      +8 -0      xml-xalan/c/src/XPath/XPathExpression.cpp
  
  Index: XPathExpression.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XPathExpression.cpp       2000/07/12 21:46:51     1.9
  +++ XPathExpression.cpp       2000/07/21 19:50:03     1.10
  @@ -688,7 +688,15 @@
        assert(thePosition < tokenQueueSize());
   
        // Set the entry in the token queue to the XObject.
  +     XObject* const  thePreviousToken = m_tokenQueue[thePosition];
  +     assert(thePreviousToken != 0);
  +
        m_tokenQueue[thePosition] = theToken;
  +
  +     if (m_xobjectFactory != 0)
  +     {
  +             m_xobjectFactory->returnObject(thePreviousToken);
  +     }
   
        // Push the index onto the op map.
        m_opMap.push_back(thePosition);
  
  
  
  1.8       +4 -4      xml-xalan/c/src/XPath/XResultTreeFrag.hpp
  
  Index: XResultTreeFrag.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XResultTreeFrag.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XResultTreeFrag.hpp       2000/07/13 22:47:16     1.7
  +++ XResultTreeFrag.hpp       2000/07/21 19:50:03     1.8
  @@ -92,22 +92,22 @@
         * @param envSupport XPath environment support class instance
         * @param support    XPath support class instance
         * @param val        source result tree fragment
  -      * @param deepClone  true to copy all subobjects, default true
  +      * @param deepClone  true to copy all subobjects, default is false
         */
        XResultTreeFrag(
                        XPathEnvSupport&                        envSupport,
                        XPathSupport&                           support,
                        const ResultTreeFragBase&       val,
  -                     bool                                            
deepClone = true);
  +                     bool                                            
deepClone = false);
   
        /**
         * Construct an XResultTreeFrag object from another
         * 
         * @param source     source XResultTreeFrag
  -      * @param deepClone  true to copy all subobjects, default true
  +      * @param deepClone  true to copy all subobjects, default is false
         */
        XResultTreeFrag(const XResultTreeFrag&  source,
  -                     bool                                                    
deepClone = true);
  +                     bool                                                    
deepClone = false);
   
        virtual
        ~XResultTreeFrag();
  
  
  
  1.9       +1 -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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XString.cpp       2000/07/13 22:47:18     1.8
  +++ XString.cpp       2000/07/21 19:50:03     1.9
  @@ -91,6 +91,7 @@
   XString::XString(const XString&      source) :
        XObject(source),
        m_value(source.m_value),
  +     m_cachedNumberValue(source.m_cachedNumberValue),
        m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
                                                0 :
                                                
source.m_resultTreeFrag->clone(true))
  
  
  

Reply via email to