dbertoni 01/03/29 14:17:47
Modified: c/src/XPath XPath.cpp XPath.hpp
Log:
Removed dead code and re-structured code a bit.
Revision Changes Path
1.47 +49 -47 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.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- XPath.cpp 2001/03/09 16:44:03 1.46
+++ XPath.cpp 2001/03/29 22:17:46 1.47
@@ -129,6 +129,7 @@
}
+
XLocator*
XPath::createXLocatorHandler() const
{
@@ -140,6 +141,7 @@
const XObjectPtr
XPath::execute(XPathExecutionContext& executionContext) const
{
+ assert(executionContext.getCurrentNode() != 0);
assert(executionContext.getPrefixResolver() != 0);
return executeMore(executionContext.getCurrentNode(), 0,
executionContext);
@@ -153,6 +155,8 @@
const PrefixResolver& prefixResolver,
XPathExecutionContext& executionContext) const
{
+ assert(context != 0);
+
// Push and pop the PrefixResolver...
XPathExecutionContext::PrefixResolverSetAndRestore
theResolverSetAndRestore(
executionContext,
@@ -175,6 +179,8 @@
const NodeRefListBase& contextNodeList,
XPathExecutionContext& executionContext) const
{
+ assert(context != 0);
+
// Push and pop the PrefixResolver...
XPathExecutionContext::ContextNodeListSetAndRestore
theSetAndRestore(
executionContext,
@@ -191,6 +197,8 @@
int opPos,
XPathExecutionContext& executionContext) const
{
+ assert(context != 0);
+
XObjectPtr result;
switch(m_expression.m_opMap[opPos])
@@ -416,6 +424,35 @@
+inline void
+XPath::doGetMatchScore(
+ XalanNode* context,
+ XPathExecutionContext& executionContext,
+ double& score) const
+{
+ int opPos = 2;
+
+ XLocator* const locator = m_defaultXLocator;
+
+ while(m_expression.m_opMap[opPos] ==
XPathExpression::eOP_LOCATIONPATHPATTERN)
+ {
+ const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
+
+ score = locator->locationPathPattern(*this, executionContext,
*context, opPos);
+
+ if(score == s_MatchScoreNone)
+ {
+ opPos = nextOpPos;
+ }
+ else
+ {
+ break;
+ }
+ }
+}
+
+
+
double
XPath::getMatchScore(XalanNode* context,
const PrefixResolver&
resolver,
@@ -423,43 +460,26 @@
{
double score = s_MatchScoreNone;
- int opPos = 0;
-
- if(m_expression.m_opMap[opPos] == XPathExpression::eOP_MATCHPATTERN)
+ if(m_expression.m_opMap[0] == XPathExpression::eOP_MATCHPATTERN)
{
assert(context != 0);
-
- // Push and pop the PrefixResolver...
- XPathExecutionContext::PrefixResolverSetAndRestore
theSetAndRestore(
-
executionContext,
-
&resolver);
-
- opPos += 2;
-#if 1
- XLocator* const locator = m_defaultXLocator;
-#else
- XLocator* locator =
executionContext.getXLocatorFromNode(context);
+ const PrefixResolver* const theCurrentResolver =
+ executionContext.getPrefixResolver();
- if(0 == locator)
+ if (theCurrentResolver == &resolver)
{
- locator = m_defaultXLocator;
+ doGetMatchScore(context, executionContext, score);
}
- assert(locator != 0);
-#endif
-
- while(m_expression.m_opMap[opPos] ==
XPathExpression::eOP_LOCATIONPATHPATTERN &&
- score == s_MatchScoreNone)
+ else
{
- const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
-
- // opPos+=2;
- score = locator->locationPathPattern(*this,
executionContext, *context, opPos);
+ // Push and pop the PrefixResolver...
+ XPathExecutionContext::PrefixResolverSetAndRestore
theSetAndRestore(
+
executionContext,
+
theCurrentResolver,
+
&resolver);
- if(score == s_MatchScoreNone)
- {
- opPos = nextOpPos;
- }
+ doGetMatchScore(context, executionContext, score);
}
}
else
@@ -1194,17 +1214,8 @@
{
assert(context != 0);
-#if 1
XLocator* const locator = m_defaultXLocator;
-#else
- XLocator* xlocator =
executionContext.getXLocatorFromNode(context);
- if(0 == xlocator)
- {
- locator = m_defaultXLocator;
- }
-#endif
-
return locator->locationPath(*this, executionContext, *context, opPos);
}
@@ -1229,16 +1240,7 @@
{
assert(context != 0);
-#if 1
XLocator* const locator = m_defaultXLocator;
-#else
- XLocator* locator = executionContext.getXLocatorFromNode(context);
-
- if(0 == locator)
- {
- locator = m_defaultXLocator;
- }
-#endif
const double result = locator->locationPathPattern(*this,
executionContext, *context, opPos);
1.21 +12 -0 xml-xalan/c/src/XPath/XPath.hpp
Index: XPath.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XPath.hpp 2001/01/24 16:12:00 1.20
+++ XPath.hpp 2001/03/29 22:17:46 1.21
@@ -485,6 +485,18 @@
protected:
/**
+ * Helper function to get match score.
+ * @param context The current source tree context node.
+ * @param executionContext The current execution context
+ * @param score The match score
+ */
+ void
+ doGetMatchScore(
+ XalanNode* context,
+ XPathExecutionContext& executionContext,
+ double& score) const;
+
+ /**
* OR two expressions and return the boolean result.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]