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/07/29 00:02:06 UTC
cvs commit: xml-xalan/c/src/XPath FunctionID.hpp MutableNodeRefList.cpp MutableNodeRefList.hpp NodeRefList.cpp NodeRefList.hpp NodeRefListBase.hpp SimpleNodeLocator.cpp XBoolean.cpp XBoolean.hpp XNodeSet.cpp XNodeSet.hpp XNull.cpp XNull.hpp XNumber.cpp XNumber.hpp XObject.hpp XObjectFactory.hpp XObjectFactoryDefault.cpp XObjectFactoryDefault.hpp XPath.cpp XPathExecutionContext.hpp XPathExecutionContextDefault.cpp XPathExecutionContextDefault.hpp XResultTreeFrag.cpp XResultTreeFrag.hpp XSpan.cpp XSpan.hpp XString.cpp XString.hpp XUnknown.cpp XUnknown.hpp
dbertoni 00/07/28 15:02:05
Modified: c/src/XPath FunctionID.hpp MutableNodeRefList.cpp
MutableNodeRefList.hpp NodeRefList.cpp
NodeRefList.hpp NodeRefListBase.hpp
SimpleNodeLocator.cpp XBoolean.cpp XBoolean.hpp
XNodeSet.cpp XNodeSet.hpp XNull.cpp XNull.hpp
XNumber.cpp XNumber.hpp XObject.hpp
XObjectFactory.hpp XObjectFactoryDefault.cpp
XObjectFactoryDefault.hpp XPath.cpp
XPathExecutionContext.hpp
XPathExecutionContextDefault.cpp
XPathExecutionContextDefault.hpp
XResultTreeFrag.cpp XResultTreeFrag.hpp XSpan.cpp
XSpan.hpp XString.cpp XString.hpp XUnknown.cpp
XUnknown.hpp
Log:
Changes for reducing dynamic allocations.
Revision Changes Path
1.9 +7 -3 xml-xalan/c/src/XPath/FunctionID.hpp
Index: FunctionID.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionID.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FunctionID.hpp 2000/05/05 15:12:17 1.8
+++ FunctionID.hpp 2000/07/28 22:01:51 1.9
@@ -146,7 +146,11 @@
assert(theDocContext != 0);
// This list will hold the nodes we find.
- MutableNodeRefList theNodeList(executionContext.createMutableNodeRefList());
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::auto_ptr;
+#endif
+
+ auto_ptr<MutableNodeRefList> theNodeList(executionContext.createMutableNodeRefList());
// If there is no context, we cannot continue.
if(0 == theDocContext)
@@ -188,14 +192,14 @@
if (theNode != 0)
{
- theNodeList.addNodeInDocOrder(theNode, true);
+ theNodeList->addNodeInDocOrder(theNode, true);
}
}
}
}
}
- return executionContext.getXObjectFactory().createNodeSet(theNodeList);
+ return executionContext.getXObjectFactory().createNodeSet(theNodeList.release());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
1.14 +25 -0 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- MutableNodeRefList.cpp 2000/07/27 20:31:29 1.13
+++ MutableNodeRefList.cpp 2000/07/28 22:01:51 1.14
@@ -369,10 +369,19 @@
void
MutableNodeRefList::clearNulls()
{
+#if 1
#if !defined(XALAN_NO_NAMESPACES)
using std::remove;
#endif
+ m_nodeList.erase(
+ remove(
+ m_nodeList.begin(),
+ m_nodeList.end(),
+ NodeListVectorType::value_type(0)),
+ m_nodeList.end());
+
+#else
NodeListVectorType::iterator i =
m_nodeList.begin();
@@ -394,6 +403,7 @@
++i;
}
}
+#endif
assert(checkForDuplicates() == false);
}
@@ -405,3 +415,18 @@
{
return m_support;
}
+
+
+
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+NodeRefListBase*
+#else
+MutableNodeRefList*
+#endif
+MutableNodeRefList::clone() const
+{
+ return new MutableNodeRefList(*this);
+}
+
+
+
1.10 +7 -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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MutableNodeRefList.hpp 2000/07/27 20:31:29 1.9
+++ MutableNodeRefList.hpp 2000/07/28 22:01:51 1.10
@@ -224,6 +224,13 @@
virtual XPathSupport*
getSupport() const;
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+ virtual NodeRefListBase*
+#else
+ virtual MutableNodeRefList*
+#endif
+ clone() const;
+
private:
XPathSupport* m_support;
1.8 +12 -0 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- NodeRefList.cpp 2000/07/21 19:50:02 1.7
+++ NodeRefList.cpp 2000/07/28 22:01:52 1.8
@@ -191,6 +191,18 @@
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+NodeRefListBase*
+#else
+NodeRefList*
+#endif
+NodeRefList::clone() const
+{
+ return new NodeRefList(*this);
+}
+
+
+
#if !defined(NDEBUG)
bool
NodeRefList::checkForDuplicates() const
1.9 +7 -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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- NodeRefList.hpp 2000/07/21 19:50:02 1.8
+++ NodeRefList.hpp 2000/07/28 22:01:52 1.9
@@ -122,6 +122,13 @@
virtual XPathSupport*
getSupport() const;
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+ virtual NodeRefListBase*
+#else
+ virtual NodeRefList*
+#endif
+ clone() const;
+
#if !defined(NDEBUG)
bool
checkForDuplicates() const;
1.6 +3 -0 xml-xalan/c/src/XPath/NodeRefListBase.hpp
Index: NodeRefListBase.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/NodeRefListBase.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NodeRefListBase.hpp 2000/04/11 14:46:10 1.5
+++ NodeRefListBase.hpp 2000/07/28 22:01:52 1.6
@@ -122,6 +122,9 @@
virtual XPathSupport*
getSupport() const = 0;
+ virtual NodeRefListBase*
+ clone() const = 0;
+
#if defined(XALAN_INLINE_INITIALIZATION)
static const unsigned int npos = UINT_MAX;
#else
1.19 +48 -39 xml-xalan/c/src/XPath/SimpleNodeLocator.cpp
Index: SimpleNodeLocator.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/SimpleNodeLocator.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- SimpleNodeLocator.cpp 2000/07/27 20:35:23 1.18
+++ SimpleNodeLocator.cpp 2000/07/28 22:01:52 1.19
@@ -110,22 +110,23 @@
XObject*
SimpleNodeLocator::connectToNodes(
- const XPath& xpath,
+ const XPath& /* xpath */,
XPathExecutionContext& executionContext,
XalanNode& /* context */,
- int opPos,
+ int /* opPos */,
const ConnectArgsVectorType& connectArgs)
{
assert(connectArgs.size() > 0 && connectArgs.size() < 3);
- const XPathExpression& currentExpression =
- xpath.getExpression();
-
XObjectFactory& theFactory =
executionContext.getXObjectFactory();
XObjectGuard results(theFactory,
- theFactory.createNodeSet(MutableNodeRefList()));
+ theFactory.createNodeSet(executionContext.createMutableNodeRefList()));
+
+#if 0
+ const XPathExpression& currentExpression =
+ xpath.getExpression();
const XalanDOMString theFileSpec = connectArgs[0]->str();
@@ -197,6 +198,7 @@
{
executionContext.warn("No files matched the file specification!");
}
+#endif
return results.release();
}
@@ -210,11 +212,15 @@
XalanNode& context,
int opPos)
{
- MutableNodeRefList mnl(executionContext.createMutableNodeRefList());
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::auto_ptr;
+#endif
+
+ auto_ptr<MutableNodeRefList> mnl(executionContext.createMutableNodeRefList());
- step(xpath, executionContext, &context, opPos + 2, mnl);
+ step(xpath, executionContext, &context, opPos + 2, *mnl.get());
- return executionContext.getXObjectFactory().createNodeSet(mnl);
+ return executionContext.getXObjectFactory().createNodeSet(mnl.release());
}
@@ -252,9 +258,10 @@
int argLen = 0;
- MutableNodeRefList subQueryResults(executionContext.createMutableNodeRefList());
-// MutableNodeRefList queryResults(subQueryResults);
+ typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
+ BorrowReturnMutableNodeRefList subQueryResults(executionContext);
+
bool shouldReorder = false;
bool continueStepRecursion = true;
@@ -265,28 +272,28 @@
case XPathExpression::eOP_FUNCTION:
case XPathExpression::eOP_GROUP:
argLen = findNodeSet(xpath, executionContext, context, opPos,
- stepType, subQueryResults);
+ stepType, *subQueryResults);
break;
case XPathExpression::eFROM_ROOT:
- argLen = findRoot(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findRoot(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eFROM_PARENT:
- argLen = findParent(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findParent(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eFROM_SELF:
- argLen = findSelf(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findSelf(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eFROM_ANCESTORS:
- argLen = findAncestors(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findAncestors(xpath, executionContext, context, opPos, stepType, *subQueryResults);
shouldReorder = true;
break;
case XPathExpression::eFROM_ANCESTORS_OR_SELF:
- argLen = findAncestorsOrSelf(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findAncestorsOrSelf(xpath, executionContext, context, opPos, stepType, *subQueryResults);
shouldReorder = true;
break;
@@ -295,7 +302,7 @@
// fall-through on purpose.
case XPathExpression::eFROM_ATTRIBUTES:
- argLen = findAttributes(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findAttributes(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eMATCH_ANY_ANCESTOR:
@@ -305,45 +312,45 @@
// fall-through on purpose.
case XPathExpression::eFROM_CHILDREN:
- argLen = findChildren(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findChildren(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eFROM_DESCENDANTS:
case XPathExpression::eFROM_DESCENDANTS_OR_SELF:
- argLen = findDescendants(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findDescendants(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eFROM_FOLLOWING:
- argLen = findFollowing(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findFollowing(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eFROM_FOLLOWING_SIBLINGS:
- argLen = findFollowingSiblings(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findFollowingSiblings(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
case XPathExpression::eFROM_PRECEDING:
- argLen = findPreceeding(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findPreceeding(xpath, executionContext, context, opPos, stepType, *subQueryResults);
shouldReorder = true;
break;
case XPathExpression::eFROM_PRECEDING_SIBLINGS:
- argLen = findPreceedingSiblings(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findPreceedingSiblings(xpath, executionContext, context, opPos, stepType, *subQueryResults);
shouldReorder = true;
break;
case XPathExpression::eFROM_NAMESPACE:
- argLen = findNamespace(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findNamespace(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
default:
- argLen = findNodesOnUnknownAxis(xpath, executionContext, context, opPos, stepType, subQueryResults);
+ argLen = findNodesOnUnknownAxis(xpath, executionContext, context, opPos, stepType, *subQueryResults);
break;
}
// Push and pop the PrefixResolver...
XPathExecutionContext::ContextNodeListSetAndRestore theSetAndRestore(
executionContext,
- subQueryResults);
+ *subQueryResults);
opPos += argLen;
@@ -355,7 +362,7 @@
executionContext,
context,
opPos,
- subQueryResults,
+ *subQueryResults,
opPos);
nextStepType = currentExpression.getOpCodeMapValue(opPos);
@@ -363,25 +370,25 @@
if(XPathExpression::eENDOP != nextStepType && continueStepRecursion == true)
{
- const unsigned int nContexts = subQueryResults.getLength();
+ const unsigned int nContexts = subQueryResults->getLength();
for(unsigned int i = 0; i < nContexts; i++)
{
- XalanNode* const node = subQueryResults.item(i);
+ XalanNode* const node = subQueryResults->item(i);
if(0 != node)
{
- MutableNodeRefList mnl(executionContext.createMutableNodeRefList());
+ BorrowReturnMutableNodeRefList mnl(executionContext);
- step(xpath, executionContext, node, opPos, mnl);
+ step(xpath, executionContext, node, opPos, *mnl);
if(queryResults.getLength() == 0)
{
- queryResults = mnl;
+ queryResults = *mnl;
}
else
{
- queryResults.addNodesInDocOrder(mnl);
+ queryResults.addNodesInDocOrder(*mnl);
}
}
}
@@ -390,11 +397,11 @@
{
if (shouldReorder == true)
{
- queryResults.addNodesInDocOrder(subQueryResults);
+ queryResults.addNodesInDocOrder(*subQueryResults);
}
else
{
- queryResults = subQueryResults;
+ queryResults = *subQueryResults;
}
}
}
@@ -645,12 +652,14 @@
XalanNode* const parentContext =
executionContext.getParentOfNode(*localContext);
+
+ typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
- MutableNodeRefList mnl(executionContext.createMutableNodeRefList());
+ BorrowReturnMutableNodeRefList mnl(executionContext);
- step(xpath, executionContext, parentContext, startOpPos, mnl);
+ step(xpath, executionContext, parentContext, startOpPos, *mnl);
- if (mnl.indexOf(localContext) == MutableNodeRefList::npos)
+ if (mnl->indexOf(localContext) == MutableNodeRefList::npos)
{
score = xpath.s_MatchScoreNone;
}
1.6 +0 -24 xml-xalan/c/src/XPath/XBoolean.cpp
Index: XBoolean.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XBoolean.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XBoolean.cpp 2000/07/13 22:47:13 1.5
+++ XBoolean.cpp 2000/07/28 22:01:52 1.6
@@ -197,30 +197,6 @@
-const MutableNodeRefList&
-XBoolean::mutableNodeset() const
-{
- error("Can't cast XBoolean to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return reinterpret_cast<MutableNodeRefList&>(dummy);
-}
-
-
-
-MutableNodeRefList&
-XBoolean::mutableNodeset()
-{
- error("Can't cast XBoolean to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return reinterpret_cast<MutableNodeRefList&>(dummy);
-}
-
-
-
void
XBoolean::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
1.7 +0 -6 xml-xalan/c/src/XPath/XBoolean.hpp
Index: XBoolean.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XBoolean.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XBoolean.hpp 2000/07/13 22:47:14 1.6
+++ XBoolean.hpp 2000/07/28 22:01:53 1.7
@@ -120,12 +120,6 @@
virtual const NodeRefListBase&
nodeset() const;
- virtual const MutableNodeRefList&
- mutableNodeset() const;
-
- virtual MutableNodeRefList&
- mutableNodeset();
-
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
1.11 +43 -38 xml-xalan/c/src/XPath/XNodeSet.cpp
Index: XNodeSet.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNodeSet.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XNodeSet.cpp 2000/07/25 18:39:25 1.10
+++ XNodeSet.cpp 2000/07/28 22:01:53 1.11
@@ -69,6 +69,7 @@
#include "ResultTreeFrag.hpp"
+#include "MutableNodeRefList.hpp"
#include "XObjectTypeCallback.hpp"
#include "XPathEnvSupport.hpp"
#include "XPathSupport.hpp"
@@ -76,44 +77,64 @@
XNodeSet::XNodeSet(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const NodeRefListBase& value) :
+ XPathEnvSupport& envSupport,
+ XPathSupport& support,
+ NodeRefListBase* value) :
XObject(&envSupport, &support),
- m_value(value),
+ m_value(value == 0 ? new NodeRefList : value),
m_cachedStringValue(),
m_cachedNumberValue(0.0),
m_resultTreeFrag()
{
+ assert(value != 0);
}
+#if 0
XNodeSet::XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
const MutableNodeRefList& value) :
XObject(&envSupport, &support),
m_value(value),
+ m_resultTreeFrag(),
m_cachedStringValue(),
- m_cachedNumberValue(0.0),
- m_resultTreeFrag()
+ m_cachedNumberValue(0.0)
{
}
+#endif
+
+
+MutableNodeRefList*
+createNodeListWithNode(
+ XPathSupport& support,
+ XalanNode* node)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::auto_ptr;
+#endif
+
+ auto_ptr<MutableNodeRefList> resultNodeList(new MutableNodeRefList(&support));
+
+ resultNodeList->addNode(node);
+
+ return resultNodeList.release();
+}
+
XNodeSet::XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
XalanNode& value) :
XObject(&envSupport, &support),
- m_value(),
+ m_value(createNodeListWithNode(support, &value)),
+ m_resultTreeFrag(),
m_cachedStringValue(),
- m_cachedNumberValue(0.0),
- m_resultTreeFrag()
+ m_cachedNumberValue(0.0)
{
- m_value.addNode(&value);
}
@@ -121,12 +142,12 @@
XNodeSet::XNodeSet(const XNodeSet& source,
bool deepClone) :
XObject(source),
- m_value(source.m_value),
- m_cachedStringValue(source.m_cachedStringValue),
- m_cachedNumberValue(source.m_cachedNumberValue),
+ m_value(source.m_value->clone()),
m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
0 :
- source.m_resultTreeFrag->clone(deepClone))
+ source.m_resultTreeFrag->clone(deepClone)),
+ m_cachedStringValue(source.m_cachedStringValue),
+ m_cachedNumberValue(source.m_cachedNumberValue)
{
}
@@ -186,7 +207,7 @@
bool
XNodeSet::boolean() const
{
- return m_value.getLength() > 0 ? true : false;
+ return m_value->getLength() > 0 ? true : false;
}
@@ -197,9 +218,9 @@
assert(m_support != 0);
if (isEmpty(m_cachedStringValue) == true &&
- m_value.getLength() > 0)
+ m_value->getLength() > 0)
{
- const XalanNode* const theNode = m_value.item(0);
+ const XalanNode* const theNode = m_value->item(0);
assert(theNode != 0);
const XalanNode::NodeType theType = theNode->getNodeType();
@@ -248,11 +269,11 @@
new ResultTreeFrag(*m_envSupport->getDOMFactory(),
*m_support);
- const int nNodes = m_value.getLength();
+ const int nNodes = m_value->getLength();
for(int i = 0; i < nNodes; i++)
{
- theFrag->appendChild(m_value.item(i)->cloneNode(true));
+ theFrag->appendChild(m_value->item(i)->cloneNode(true));
}
#if defined(XALAN_OLD_AUTO_PTR)
@@ -295,11 +316,11 @@
m_resultTreeFrag.reset(theFrag);
#endif
- const int nNodes = m_value.getLength();
+ const int nNodes = m_value->getLength();
for(int i = 0; i < nNodes; i++)
{
- m_resultTreeFrag->appendChild(m_value.item(i)->cloneNode(true));
+ m_resultTreeFrag->appendChild(m_value->item(i)->cloneNode(true));
}
}
@@ -310,24 +331,8 @@
const NodeRefListBase&
XNodeSet::nodeset() const
-{
- return m_value;
-}
-
-
-
-const MutableNodeRefList&
-XNodeSet::mutableNodeset() const
-{
- return m_value;
-}
-
-
-
-MutableNodeRefList&
-XNodeSet::mutableNodeset()
{
- return m_value;
+ return *m_value.get();
}
1.11 +14 -36 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XNodeSet.hpp 2000/07/25 18:39:52 1.10
+++ XNodeSet.hpp 2000/07/28 22:01:53 1.11
@@ -73,16 +73,10 @@
-#include <XPath/ResultTreeFragBase.hpp>
-#include <XPath/MutableNodeRefList.hpp>
-
-
-
class NodeRefListBase;
-
-
-
+class ResultTreeFragBase;
class XPathSupport;
+class XalanNode;
@@ -98,24 +92,12 @@
*
* @param envSupport XPath environment support class instance
* @param support XPath support class instance
- * @param value source node list
+ * @param value Pointer to source node list. The XNodeSet will adopt the pointer.
*/
XNodeSet(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const NodeRefListBase& value = MutableNodeRefList());
-
- /**
- * Create an XNodeSet from a node list.
- *
- * @param envSupport XPath environment support class instance
- * @param support XPath support class instance
- * @param value source node list
- */
- XNodeSet(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const MutableNodeRefList& value = MutableNodeRefList());
+ XPathEnvSupport& envSupport,
+ XPathSupport& support,
+ NodeRefListBase* value = 0);
/**
* Create an XNodeSet from a node.
@@ -175,12 +157,6 @@
virtual const NodeRefListBase&
nodeset() const;
- virtual const MutableNodeRefList&
- mutableNodeset() const;
-
- virtual MutableNodeRefList&
- mutableNodeset();
-
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
@@ -194,17 +170,19 @@
operator=(const XNodeSet&);
// Data members...
- MutableNodeRefList m_value;
-
- mutable XalanDOMString m_cachedStringValue;
-
- mutable double m_cachedNumberValue;
-
#if defined(XALAN_NO_NAMESPACES)
+ auto_ptr<NodeRefListBase> m_value;
+
mutable auto_ptr<ResultTreeFragBase> m_resultTreeFrag;
#else
+ std::auto_ptr<NodeRefListBase> m_value;
+
mutable std::auto_ptr<ResultTreeFragBase> m_resultTreeFrag;
#endif
+
+ mutable XalanDOMString m_cachedStringValue;
+
+ mutable double m_cachedNumberValue;
};
1.6 +0 -24 xml-xalan/c/src/XPath/XNull.cpp
Index: XNull.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNull.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XNull.cpp 2000/07/13 22:47:15 1.5
+++ XNull.cpp 2000/07/28 22:01:54 1.6
@@ -176,30 +176,6 @@
-const MutableNodeRefList&
-XNull::mutableNodeset() const
-{
- error("Can't cast XNull to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
-MutableNodeRefList&
-XNull::mutableNodeset()
-{
- error("Can't cast XNull to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
void
XNull::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
1.8 +0 -6 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XNull.hpp 2000/07/21 19:50:02 1.7
+++ XNull.hpp 2000/07/28 22:01:54 1.8
@@ -145,12 +145,6 @@
virtual const NodeRefListBase&
nodeset() const;
- virtual const MutableNodeRefList&
- mutableNodeset() const;
-
- virtual MutableNodeRefList&
- mutableNodeset();
-
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
1.8 +0 -24 xml-xalan/c/src/XPath/XNumber.cpp
Index: XNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNumber.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XNumber.cpp 2000/07/13 22:47:15 1.7
+++ XNumber.cpp 2000/07/28 22:01:54 1.8
@@ -192,30 +192,6 @@
-const MutableNodeRefList&
-XNumber::mutableNodeset() const
-{
- error("Can't cast XNumber to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
-MutableNodeRefList&
-XNumber::mutableNodeset()
-{
- error("Can't cast XNumber to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
void
XNumber::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
1.8 +0 -6 xml-xalan/c/src/XPath/XNumber.hpp
Index: XNumber.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNumber.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XNumber.hpp 2000/07/13 22:47:15 1.7
+++ XNumber.hpp 2000/07/28 22:01:54 1.8
@@ -126,12 +126,6 @@
virtual const NodeRefListBase&
nodeset() const;
- virtual const MutableNodeRefList&
- mutableNodeset() const;
-
- virtual MutableNodeRefList&
- mutableNodeset();
-
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
1.9 +0 -16 xml-xalan/c/src/XPath/XObject.hpp
Index: XObject.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObject.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XObject.hpp 2000/07/13 22:47:16 1.8
+++ XObject.hpp 2000/07/28 22:01:55 1.9
@@ -163,22 +163,6 @@
nodeset() const = 0;
/**
- * Cast result object to a nodelist that is mutable.
- *
- * @return mutable node list
- */
- virtual const MutableNodeRefList&
- mutableNodeset() const = 0;
-
- /**
- * Cast result object to a nodelist that is mutable.
- *
- * @return mutable node list
- */
- virtual MutableNodeRefList&
- mutableNodeset() = 0;
-
- /**
* Process a callback request for preferred type information.
*
* @param theCallbackObject object to call back
1.8 +9 -33 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XObjectFactory.hpp 2000/07/25 14:48:12 1.7
+++ XObjectFactory.hpp 2000/07/28 22:01:55 1.8
@@ -139,26 +139,14 @@
/**
* Create a node set XObject from a node list.
*
- * @param theValue value used to create object
- * @param fOptimize not used
- * @return pointer to new object
- */
- virtual XObject*
- createNodeSet(
- const NodeRefListBase& theValue,
- bool fOptimize = true) = 0;
-
- /**
- * Create a node set XObject from a mutable node list.
- *
- * @param theValue value used to create object
+ * @param theValue value used to create object. theValue will be owned by the new XObject.
* @param fOptimize not used
* @return pointer to new object
*/
virtual XObject*
createNodeSet(
- const MutableNodeRefList& theValue,
- bool fOptimize = true) = 0;
+ NodeRefListBase* theValue,
+ bool fOptimize = true) = 0;
/**
* Create a node set XObject from a DOM node.
@@ -222,38 +210,26 @@
/**
* Create a result tree fragment XObject from a result tree fragment.
*
- * @param theValue value used to create object
+ * @param theValue value used to create object. theValue will be owned by the new XObject.
* @param fOptimize not used
* @return pointer to new object
*/
virtual XObject*
createResultTreeFrag(
- const ResultTreeFragBase& theValue,
- bool fOptimize = true) = 0;
-
- /**
- * Create a span XObject from a node list.
- *
- * @param theValue value used to create object
- * @param fOptimize not used
- * @return pointer to new object
- */
- virtual XObject*
- createSpan(
- const NodeRefListBase& theValue,
+ ResultTreeFragBase* theValue,
bool fOptimize = true) = 0;
/**
- * Create a span XObject from a mutable node list.
+ * Create a span XObject from a node list.
*
- * @param theValue value used to create object
+ * @param theValue value used to create object. The new object will own the pointer.
* @param fOptimize not used
* @return pointer to new object
*/
virtual XObject*
createSpan(
- const MutableNodeRefList& theValue,
- bool fOptimize = true) = 0;
+ NodeRefListBase* theValue,
+ bool fOptimize = true) = 0;
/**
* Create a span XObject from a DOM node.
1.11 +6 -42 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XObjectFactoryDefault.cpp 2000/07/17 14:52:33 1.10
+++ XObjectFactoryDefault.cpp 2000/07/28 22:01:56 1.11
@@ -204,26 +204,8 @@
XObject*
XObjectFactoryDefault::createNodeSet(
- const NodeRefListBase& value,
- bool /* fOptimize */)
-{
- XNodeSet* const theXNodeSet = new XNodeSet(m_envSupport, m_support, value);
-
- m_xobjects.insert(theXNodeSet);
-
-#if !defined(NDEBUG)
- ++m_totalNodeSetInstanceCount;
-#endif
-
- return theXNodeSet;
-}
-
-
-
-XObject*
-XObjectFactoryDefault::createNodeSet(
- const MutableNodeRefList& value,
- bool /* fOptimize */)
+ NodeRefListBase* value,
+ bool /* fOptimize */)
{
XNodeSet* const theXNodeSet = new XNodeSet(m_envSupport, m_support, value);
@@ -335,8 +317,8 @@
XObject*
XObjectFactoryDefault::createResultTreeFrag(
- const ResultTreeFragBase& theValue,
- bool /* fOptimize */)
+ ResultTreeFragBase* theValue,
+ bool /* fOptimize */)
{
XResultTreeFrag* const theResultTreeFrag = new XResultTreeFrag(m_envSupport, m_support, theValue);
@@ -352,27 +334,9 @@
XObject*
-XObjectFactoryDefault::createSpan(
- const NodeRefListBase& theValue,
- bool /* fOptimize */)
-{
- XSpan* const theXSpan = new XSpan(m_envSupport, m_support, theValue);
-
- m_xobjects.insert(theXSpan);
-
-#if !defined(NDEBUG)
- ++m_totalSpanInstanceCount;
-#endif
-
- return theXSpan;
-}
-
-
-
-XObject*
XObjectFactoryDefault::createSpan(
- const MutableNodeRefList& theValue,
- bool /* fOptimize */)
+ NodeRefListBase* theValue,
+ bool /* fOptimize */)
{
XSpan* const theXSpan = new XSpan(m_envSupport, m_support, theValue);
1.8 +5 -15 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XObjectFactoryDefault.hpp 2000/07/12 21:46:51 1.7
+++ XObjectFactoryDefault.hpp 2000/07/28 22:01:56 1.8
@@ -117,13 +117,8 @@
virtual XObject*
createNodeSet(
- const NodeRefListBase& value,
- bool fOptimize = true);
-
- virtual XObject*
- createNodeSet(
- const MutableNodeRefList& value,
- bool fOptimize = true);
+ NodeRefListBase* value,
+ bool fOptimize = true);
virtual XObject*
createNodeSet(
@@ -150,18 +145,13 @@
virtual XObject*
createResultTreeFrag(
- const ResultTreeFragBase& theValue,
- bool fOptimize = true);
-
- virtual XObject*
- createSpan(
- const NodeRefListBase& value,
+ ResultTreeFragBase* theValue,
bool fOptimize = true);
virtual XObject*
createSpan(
- const MutableNodeRefList& value,
- bool fOptimize = true);
+ NodeRefListBase* value,
+ bool fOptimize = true);
virtual XObject*
createSpan(
1.23 +20 -17 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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XPath.cpp 2000/07/27 20:35:23 1.22
+++ XPath.cpp 2000/07/28 22:01:56 1.23
@@ -1115,8 +1115,12 @@
{
opPos += 2;
- XObject* resultNodeSet = 0;
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::auto_ptr;
+#endif
+ auto_ptr<MutableNodeRefList> resultNodeList(executionContext.createMutableNodeRefList());
+
XObjectFactory& theFactory = executionContext.getXObjectFactory();
while(m_expression.m_opMap[opPos] != XPathExpression::eENDOP)
@@ -1125,24 +1129,17 @@
XObject* expr = executeMore(context, opPos, executionContext);
- if(0 == resultNodeSet)
- {
- resultNodeSet = expr;
- }
- else
- {
- MutableNodeRefList& nl =
- resultNodeSet->mutableNodeset();
+ const NodeRefListBase& nl =
+ expr->nodeset();
- nl.addNodesInDocOrder(expr->nodeset());
+ resultNodeList->addNodesInDocOrder(nl);
- theFactory.returnObject(expr);
- }
+ theFactory.returnObject(expr);
opPos = nextOpPos;
}
- return resultNodeSet;
+ return theFactory.createNodeSet(resultNodeList.release());
}
@@ -1351,10 +1348,13 @@
const XObject* const funcName = m_expression.m_tokenQueue[m_expression.m_opMap[opPos]];
opPos++;
+
+ typedef XPathExecutionContext::XObjectArgVectorType XObjectArgVectorType;
+ typedef XPathExecutionContext::PushPopArgVector PushPopArgVector;
- Function::XObjectArgVectorType args;
+ PushPopArgVector thePushPop(executionContext);
- args.reserve(eDefaultArgVectorSize);
+ XObjectArgVectorType& args = thePushPop.getVector();
while(opPos < endExtFunc)
{
@@ -1415,10 +1415,13 @@
const int funcID = m_expression.m_opMap[opPos];
opPos++;
+
+ typedef XPathExecutionContext::XObjectArgVectorType XObjectArgVectorType;
+ typedef XPathExecutionContext::PushPopArgVector PushPopArgVector;
- Function::XObjectArgVectorType args;
+ PushPopArgVector thePushPop(executionContext);
- args.reserve(eDefaultArgVectorSize);
+ XObjectArgVectorType& args = thePushPop.getVector();
while(opPos < endFunc)
{
1.17 +99 -2 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XPathExecutionContext.hpp 2000/07/14 16:57:13 1.16
+++ XPathExecutionContext.hpp 2000/07/28 22:01:56 1.17
@@ -66,6 +66,7 @@
+#include <cassert>
#include <vector>
@@ -334,6 +335,50 @@
const XObjectArgVectorType& argVec) = 0;
/**
+ * Push an arg vector on the execution context and
+ * return a reference to it. Must be followed by
+ * a pop.
+ *
+ * @return a reference to an arg vector.
+ */
+ virtual XObjectArgVectorType&
+ pushArgVector() = 0;
+
+ /**
+ * Pop the arg vector from the execution context.
+ */
+ virtual void
+ popArgVector() = 0;
+
+ class PushPopArgVector
+ {
+ public:
+
+ PushPopArgVector(XPathExecutionContext& executionContext) :
+ m_xpathExecutionContext(executionContext),
+ m_argVector(executionContext.pushArgVector())
+ {
+ }
+
+ ~PushPopArgVector()
+ {
+ m_xpathExecutionContext.popArgVector();
+ }
+
+ XObjectArgVectorType&
+ getVector()
+ {
+ return m_argVector;
+ }
+
+ private:
+
+ XPathExecutionContext& m_xpathExecutionContext;
+
+ XObjectArgVectorType& m_argVector;
+ };
+
+ /**
* Get an XLocator provider keyed by node. This gets the association
* based on the root of the tree that is the node's parent.
*
@@ -368,11 +413,63 @@
const XalanDOMString& base) const = 0;
/**
+ * Borrow a cached MutableNodeRefList.
+ *
+ * @return A pointer the to node list.
+ */
+ virtual MutableNodeRefList*
+ borrowMutableNodeRefList() = 0;
+
+ /**
+ * Return a previously borrowed MutableNodeRefList.
+ *
+ * @param theList A pointer the to previously borrowed node list.
+ * @return true if the list was borrowed (at therefore, destroyed), false if not.
+ */
+ virtual bool
+ returnMutableNodeRefList(MutableNodeRefList* theList) = 0;
+
+ class BorrowReturnMutableNodeRefList
+ {
+ public:
+
+ BorrowReturnMutableNodeRefList(XPathExecutionContext& executionContext) :
+ m_xpathExecutionContext(executionContext),
+ m_mutableNodeRefList(executionContext.borrowMutableNodeRefList())
+ {
+ assert(m_mutableNodeRefList != 0);
+ }
+
+ ~BorrowReturnMutableNodeRefList()
+ {
+ m_xpathExecutionContext.returnMutableNodeRefList(m_mutableNodeRefList);
+ }
+
+ MutableNodeRefList&
+ operator*() const
+ {
+ return *m_mutableNodeRefList;
+ }
+
+ MutableNodeRefList*
+ operator->() const
+ {
+ return m_mutableNodeRefList;
+ }
+
+ private:
+
+ XPathExecutionContext& m_xpathExecutionContext;
+
+ MutableNodeRefList* m_mutableNodeRefList;
+ };
+
+ /**
* Create a MutableNodeRefList with the appropriate context.
*
- * @return node list created
+ * @return pointer to node list created
*/
- virtual MutableNodeRefList
+ virtual MutableNodeRefList*
createMutableNodeRefList() const = 0;
/**
1.14 +127 -3 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XPathExecutionContextDefault.cpp 2000/07/21 19:50:03 1.13
+++ XPathExecutionContextDefault.cpp 2000/07/28 22:01:57 1.14
@@ -62,6 +62,10 @@
+#include <PlatformSupport/STLHelper.hpp>
+
+
+
#include "ElementPrefixResolverProxy.hpp"
#include "FoundIndex.hpp"
#include "XObjectFactory.hpp"
@@ -86,14 +90,37 @@
m_currentNode(theCurrentNode),
m_contextNodeList(&theContextNodeList),
m_prefixResolver(thePrefixResolver),
- m_throwFoundIndex(false)
+ m_throwFoundIndex(false),
+ m_availableCachedNodeLists(),
+ m_busyCachedNodeLists(),
+ m_argVectorsStack(),
+ m_argVectorsStackPosition(m_argVectorsStack.end())
{
+ m_availableCachedNodeLists.reserve(eMutableNodeRefListCacheMax);
+
+ m_busyCachedNodeLists.reserve(eMutableNodeRefListCacheMax);
}
XPathExecutionContextDefault::~XPathExecutionContextDefault()
{
+ assert(m_busyCachedNodeLists.size() == 0);
+ assert(m_argVectorsStackPosition == m_argVectorsStack.begin() ||
+ m_argVectorsStack.size() == 0);
+
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ for_each(
+ m_availableCachedNodeLists.begin(),
+ m_availableCachedNodeLists.end(),
+ DeleteFunctor<MutableNodeRefList>());
+
+ m_argVectorsStack.clear();
+
+ m_argVectorsStackPosition = m_argVectorsStack.end();
}
@@ -248,6 +275,53 @@
+XPathExecutionContextDefault::XObjectArgVectorType&
+XPathExecutionContextDefault::pushArgVector()
+{
+ // m_argVectorsStackPosition always points one past
+ // the current top of the stack.
+ if (m_argVectorsStackPosition != m_argVectorsStack.end())
+ {
+ return *m_argVectorsStackPosition++;
+ }
+ else
+ {
+ m_argVectorsStack.push_back(XObjectArgVectorType());
+
+ m_argVectorsStackPosition = m_argVectorsStack.end();
+
+ XObjectArgVectorType& theResult =
+ m_argVectorsStack.back();
+
+ theResult.reserve(eCachedArgVectorDefaultSize);
+
+ return theResult;
+ }
+}
+
+
+
+void
+XPathExecutionContextDefault::popArgVector()
+{
+ assert(m_argVectorsStackPosition != m_argVectorsStack.begin());
+
+ if (m_argVectorsStack.size() > eArgVectorStackMax)
+ {
+ m_argVectorsStack.pop_back();
+
+ m_argVectorsStackPosition = m_argVectorsStack.end();
+ }
+ else
+ {
+ m_argVectorsStackPosition->clear();
+
+ --m_argVectorsStackPosition;
+ }
+}
+
+
+
XObject*
XPathExecutionContextDefault::extFunction(
const XalanDOMString& theNamespace,
@@ -287,11 +361,61 @@
}
+
+MutableNodeRefList*
+XPathExecutionContextDefault::borrowMutableNodeRefList()
+{
+ // We'll always return the back of the free list, since
+ // that's the cheapest thing.
+ if (m_availableCachedNodeLists.size() == 0)
+ {
+ m_busyCachedNodeLists.push_back(new MutableNodeRefList(&m_xpathSupport));
+ }
+ else
+ {
+ m_busyCachedNodeLists.push_back(m_availableCachedNodeLists.back());
+
+ m_availableCachedNodeLists.pop_back();
+ }
+
+ return m_busyCachedNodeLists.back();
+}
+
+
+
+bool
+XPathExecutionContextDefault::returnMutableNodeRefList(MutableNodeRefList* theList)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ // Search from the back to the front, since we push the latest borrowed on the back.
+ const NodeRefListCacheType::reverse_iterator i =
+ find(m_busyCachedNodeLists.rbegin(), m_busyCachedNodeLists.rend(), theList);
+
+ if (i == m_busyCachedNodeLists.rend())
+ {
+ return false;
+ }
+ else
+ {
+ theList->clear();
+
+ m_availableCachedNodeLists.push_back(*i);
+
+ m_busyCachedNodeLists.erase(&*i);
+
+ return true;
+ }
+}
+
+
-MutableNodeRefList
+MutableNodeRefList*
XPathExecutionContextDefault::createMutableNodeRefList() const
{
- return MutableNodeRefList(&m_xpathSupport);
+ return new MutableNodeRefList(&m_xpathSupport);
}
1.15 +39 -1 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XPathExecutionContextDefault.hpp 2000/07/14 16:57:13 1.14
+++ XPathExecutionContextDefault.hpp 2000/07/28 22:01:57 1.15
@@ -69,6 +69,10 @@
+#include <deque>
+
+
+
#include <XalanDOM/XalanDOMString.hpp>
@@ -170,6 +174,12 @@
const XalanDOMString& theNamespace,
const XalanDOMString& functionName) const;
+ virtual XObjectArgVectorType&
+ pushArgVector();
+
+ virtual void
+ popArgVector();
+
virtual XObject*
extFunction(
const XalanDOMString& theNamespace,
@@ -189,8 +199,14 @@
parseXML(
const XalanDOMString& urlString,
const XalanDOMString& base) const;
+
+ virtual MutableNodeRefList*
+ borrowMutableNodeRefList();
- virtual MutableNodeRefList
+ virtual bool
+ returnMutableNodeRefList(MutableNodeRefList* theList);
+
+ virtual MutableNodeRefList*
createMutableNodeRefList() const;
virtual bool
@@ -286,6 +302,20 @@
protected:
+#if defined(XALAN_NO_NAMESPACES)
+ typedef vector<MutableNodeRefList*> NodeRefListCacheType;
+ typedef deque<XObjectArgVectorType> XObjectArgVectorStackType;
+#else
+ typedef std::vector<MutableNodeRefList*> NodeRefListCacheType;
+ typedef std::deque<XObjectArgVectorType> XObjectArgVectorStackType;
+#endif
+
+ typedef XObjectArgVectorStackType::iterator ArgVectorStackIteratorType;
+
+ enum { eMutableNodeRefListCacheMax = 50,
+ eArgVectorStackMax = 25,
+ eCachedArgVectorDefaultSize = 10 };
+
XPathEnvSupport& m_xpathEnvSupport;
XPathSupport& m_xpathSupport;
@@ -301,6 +331,14 @@
bool m_throwFoundIndex;
XalanDOMString m_currentPattern;
+
+ NodeRefListCacheType m_availableCachedNodeLists;
+
+ NodeRefListCacheType m_busyCachedNodeLists;
+
+ XObjectArgVectorStackType m_argVectorsStack;
+
+ ArgVectorStackIteratorType m_argVectorsStackPosition;
};
1.9 +12 -29 xml-xalan/c/src/XPath/XResultTreeFrag.cpp
Index: XResultTreeFrag.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XResultTreeFrag.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XResultTreeFrag.cpp 2000/07/27 20:34:34 1.8
+++ XResultTreeFrag.cpp 2000/07/28 22:01:57 1.9
@@ -77,13 +77,12 @@
XResultTreeFrag::XResultTreeFrag(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const ResultTreeFragBase& val,
- bool deepClone) :
+ XPathEnvSupport& envSupport,
+ XPathSupport& support,
+ ResultTreeFragBase* val) :
XObject(&envSupport, &support),
NodeRefListBase(),
- m_value(val.clone(deepClone)),
+ m_value(val),
m_cachedStringValue(),
m_cachedNumberValue(0.0)
{
@@ -228,30 +227,6 @@
-const MutableNodeRefList&
-XResultTreeFrag::mutableNodeset() const
-{
- error("Can't cast XResultTreeFrag to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
-MutableNodeRefList&
-XResultTreeFrag::mutableNodeset()
-{
- error("Can't cast XResultTreeFrag to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
void
XResultTreeFrag::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
@@ -345,4 +320,12 @@
XResultTreeFrag::getSupport() const
{
return m_support;
+}
+
+
+
+NodeRefListBase*
+XResultTreeFrag::clone() const
+{
+ return new XResultTreeFrag(*this);
}
1.10 +8 -12 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XResultTreeFrag.hpp 2000/07/27 20:34:34 1.9
+++ XResultTreeFrag.hpp 2000/07/28 22:01:57 1.10
@@ -91,14 +91,13 @@
*
* @param envSupport XPath environment support class instance
* @param support XPath support class instance
- * @param val source result tree fragment
+ * @param val source result tree fragment. The XResultTreeFrag instance will adopt the object.
* @param deepClone true to copy all subobjects, default is false
*/
XResultTreeFrag(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const ResultTreeFragBase& val,
- bool deepClone = false);
+ XPathEnvSupport& envSupport,
+ XPathSupport& support,
+ ResultTreeFragBase* val);
/**
* Construct an XResultTreeFrag object from another
@@ -112,7 +111,7 @@
virtual
~XResultTreeFrag();
-
+
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
@@ -146,12 +145,6 @@
virtual const NodeRefListBase&
nodeset() const;
- virtual const MutableNodeRefList&
- mutableNodeset() const;
-
- virtual MutableNodeRefList&
- mutableNodeset();
-
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
@@ -176,6 +169,9 @@
virtual XPathSupport*
getSupport() const;
+
+ virtual NodeRefListBase*
+ clone() const;
#if defined(XALAN_NO_NAMESPACES)
auto_ptr<ResultTreeFragBase> m_value;
1.5 +5 -3 xml-xalan/c/src/XPath/XSpan.cpp
Index: XSpan.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XSpan.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSpan.cpp 2000/07/13 22:47:17 1.4
+++ XSpan.cpp 2000/07/28 22:01:58 1.5
@@ -59,9 +59,9 @@
XSpan::XSpan(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const NodeRefListBase& value) :
+ XPathEnvSupport& envSupport,
+ XPathSupport& support,
+ NodeRefListBase* value) :
XNodeSet(envSupport,
support,
value),
@@ -72,6 +72,7 @@
+#if 0
XSpan::XSpan(
XPathEnvSupport& envSupport,
XPathSupport& support,
@@ -83,6 +84,7 @@
m_end(-1)
{
}
+#endif
1.6 +4 -16 xml-xalan/c/src/XPath/XSpan.hpp
Index: XSpan.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XSpan.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSpan.hpp 2000/07/13 22:47:17 1.5
+++ XSpan.hpp 2000/07/28 22:01:58 1.6
@@ -78,24 +78,12 @@
*
* @param envSupport XPath environment support class instance
* @param support XPath support class instance
- * @param value source node list
+ * @param value source node list. The instance will adopt the value instance.
*/
XSpan(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const NodeRefListBase& value = MutableNodeRefList());
-
- /**
- * Construct an XSpan object from a node list.
- *
- * @param envSupport XPath environment support class instance
- * @param support XPath support class instance
- * @param value source node list
- */
- XSpan(
- XPathEnvSupport& envSupport,
- XPathSupport& support,
- const MutableNodeRefList& value = MutableNodeRefList());
+ XPathEnvSupport& envSupport,
+ XPathSupport& support,
+ NodeRefListBase* value = 0);
/**
* Construct an XSpan object from a DOM node.
1.10 +0 -24 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XString.cpp 2000/07/21 19:50:03 1.9
+++ XString.cpp 2000/07/28 22:01:58 1.10
@@ -279,30 +279,6 @@
-const MutableNodeRefList&
-XString::mutableNodeset() const
-{
- error("Can't cast XString to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
-MutableNodeRefList&
-XString::mutableNodeset()
-{
- error("Can't cast XString to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
void
XString::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
1.9 +0 -6 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XString.hpp 2000/07/13 22:47:18 1.8
+++ XString.hpp 2000/07/28 22:01:59 1.9
@@ -138,12 +138,6 @@
virtual const NodeRefListBase&
nodeset() const;
- virtual const MutableNodeRefList&
- mutableNodeset() const;
-
- virtual MutableNodeRefList&
- mutableNodeset();
-
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
1.6 +0 -24 xml-xalan/c/src/XPath/XUnknown.cpp
Index: XUnknown.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XUnknown.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XUnknown.cpp 2000/07/13 22:47:18 1.5
+++ XUnknown.cpp 2000/07/28 22:01:59 1.6
@@ -180,30 +180,6 @@
-const MutableNodeRefList&
-XUnknown::mutableNodeset() const
-{
- error("Can't cast XUnknown to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
-MutableNodeRefList&
-XUnknown::mutableNodeset()
-{
- error("Can't cast XUnknown to MutableNodeRefList");
-
- // error will throw, so this is just a dummy
- // value to satisfy the compiler.
- return *static_cast<MutableNodeRefList*>(0);
-}
-
-
-
void
XUnknown::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
1.7 +0 -6 xml-xalan/c/src/XPath/XUnknown.hpp
Index: XUnknown.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XUnknown.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XUnknown.hpp 2000/07/13 22:47:19 1.6
+++ XUnknown.hpp 2000/07/28 22:01:59 1.7
@@ -126,12 +126,6 @@
virtual const NodeRefListBase&
nodeset() const;
- virtual const MutableNodeRefList&
- mutableNodeset() const;
-
- virtual MutableNodeRefList&
- mutableNodeset();
-
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);