dbertoni    00/07/07 15:53:10

  Modified:    c/src/XPath MutableNodeRefList.cpp MutableNodeRefList.hpp
  Log:
  Delay vector allocation until necessary.
  
  Revision  Changes    Path
  1.11      +9 -4      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MutableNodeRefList.cpp    2000/07/06 20:16:27     1.10
  +++ MutableNodeRefList.cpp    2000/07/07 22:53:08     1.11
  @@ -78,7 +78,6 @@
        NodeRefList(),
        m_support(theSupport)
   {
  -     m_nodeList.reserve(eDefaultVectorSize);
   }
   
   
  @@ -167,6 +166,8 @@
   {
        if (n != 0)
        {
  +             ensureAllocation();
  +
                m_nodeList.push_back(n);
        }
   }
  @@ -182,6 +183,8 @@
   
        if (n != 0)
        {
  +             ensureAllocation();
  +
                m_nodeList.insert(&m_nodeList[pos], n);
        }
   }
  @@ -269,7 +272,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++)
        {
  @@ -288,7 +291,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++)
        {
  @@ -307,7 +310,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++)
        {
  @@ -324,6 +327,8 @@
   {
        if (node != 0)
        {
  +             ensureAllocation();
  +
                const unsigned int      size = getLength();
   
                if (test == false || m_support == 0 || size == 0)
  
  
  
  1.7       +14 -0     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MutableNodeRefList.hpp    2000/07/06 20:16:27     1.6
  +++ MutableNodeRefList.hpp    2000/07/07 22:53:08     1.7
  @@ -227,6 +227,20 @@
                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;
  
  
  

Reply via email to