You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/12/21 05:28:53 UTC

cvs commit: xml-xalan/c/src/XPath MutableNodeRefList.cpp MutableNodeRefList.hpp

dbertoni    00/12/20 20:28:53

  Modified:    c/src/XPath MutableNodeRefList.cpp MutableNodeRefList.hpp
  Log:
  Disabled ensureAllocation() for now, since it actually seems to harm performance.
  
  Revision  Changes    Path
  1.18      +38 -24    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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MutableNodeRefList.cpp	2000/12/04 20:46:16	1.17
  +++ MutableNodeRefList.cpp	2000/12/21 04:28:53	1.18
  @@ -165,7 +165,7 @@
   {
   	if (n != 0)
   	{
  -		ensureAllocation();
  +		// ensureAllocation();
   
   		m_nodeList.push_back(n);
   	}
  @@ -182,7 +182,7 @@
   
   	if (n != 0)
   	{
  -		ensureAllocation();
  +		// ensureAllocation();
   
   		m_nodeList.insert(m_nodeList.begin() + pos, n);
   	}
  @@ -240,16 +240,42 @@
   
   
   
  +inline void
  +MutableNodeRefList::ensureAllocation(NodeListVectorType::size_type	/* theSize */)
  +{
  +	// This code is commmented out for now, since it appears to actual hurt
  +	// performance, rather than help.
  +#if 0
  +	const unsigned int	theNodeListSize = m_nodeList.size();
  +
  +	if (theSize > theNodeListSize)
  +	{
  +		const unsigned int	theNewSize = theNodeListSize * 2;
  +
  +		if (theSize > theNewSize)
  +		{
  +			m_nodeList.reserve(theSize * 2);
  +		}
  +		else
  +		{
  +			m_nodeList.reserve(theNewSize);
  +		}
  +	}
  +	else
  +	{
  +		m_nodeList.reserve(eDefaultVectorSize);
  +	}
  +#endif
  +}
  +
  +
  +
   void
   MutableNodeRefList::addNodes(const XalanNodeList&	nodelist)
   {
   	const unsigned int	theLength = nodelist.getLength();
   
  -	// Reserve the space at the start.  We may end up reserving
  -	// 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 too much space.
  -	ensureAllocation(m_nodeList.size() + theLength);
  +	// ensureAllocation(m_nodeList.size() + theLength);
   
   	for (unsigned int i = 0; i < theLength; i++)
   	{
  @@ -264,11 +290,7 @@
   {
   	const unsigned int	theLength = nodelist.getLength();
   
  -	// Reserve the space at the start.  We may end up reserving
  -	// 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 too much space.
  -	ensureAllocation(m_nodeList.size() + theLength);
  +	// ensureAllocation(m_nodeList.size() + theLength);
   
   	for (unsigned int i = 0; i < theLength; i++)
   	{
  @@ -285,11 +307,7 @@
   {
   	const unsigned int	theLength = nodelist.getLength();
   
  -	// Reserve the space at the start.  We may end up reserving
  -	// 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 too much space.
  -	ensureAllocation(m_nodeList.size() + theLength);
  +	// ensureAllocation(m_nodeList.size() + theLength);
   
   	for(unsigned int i = 0; i < theLength; i++)
   	{
  @@ -306,11 +324,7 @@
   {
   	const unsigned int	theLength = nodelist.getLength();
   
  -	// Reserve the space at the start.  We may end up reserving
  -	// 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 too much space.
  -	ensureAllocation(m_nodeList.size() + theLength);
  +	// ensureAllocation(m_nodeList.size() + theLength);
   
   	for(unsigned int i = 0; i < theLength; i++)
   	{
  @@ -539,9 +553,9 @@
   {
   	if (node != 0)
   	{
  -		ensureAllocation();
  -
   		const unsigned int	size = m_nodeList.size();
  +
  +		// ensureAllocation(size + 1);
   
   		if (size == 0)
   		{
  
  
  
  1.13      +5 -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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MutableNodeRefList.hpp	2000/12/04 20:46:16	1.12
  +++ MutableNodeRefList.hpp	2000/12/21 04:28:53	1.13
  @@ -227,6 +227,11 @@
   	clearNulls();
   
   	typedef NodeListVectorType::iterator	NodeListIteratorType;
  +
  +private:
  +
  +	void
  +	ensureAllocation(NodeListVectorType::size_type	theSize = 0);
   };