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:29:30 UTC
cvs commit: xml-xalan/c/src/XPath FunctionConcat.cpp FunctionLocalName.cpp FunctionName.cpp FunctionNamespaceURI.cpp FunctionString.cpp FunctionSubstring.cpp FunctionSubstringAfter.cpp FunctionSubstringBefore.cpp FunctionTranslate.cpp
dbertoni 00/12/20 20:29:30
Modified: c/src/XPath FunctionConcat.cpp FunctionLocalName.cpp
FunctionName.cpp FunctionNamespaceURI.cpp
FunctionString.cpp FunctionSubstring.cpp
FunctionSubstringAfter.cpp
FunctionSubstringBefore.cpp FunctionTranslate.cpp
Log:
Use new cached string implementation.
Revision Changes Path
1.8 +9 -9 xml-xalan/c/src/XPath/FunctionConcat.cpp
Index: FunctionConcat.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionConcat.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FunctionConcat.cpp 2000/12/06 21:00:07 1.7
+++ FunctionConcat.cpp 2000/12/21 04:29:29 1.8
@@ -108,15 +108,15 @@
{
assert(arg1.null() == false && arg2.null() == false);
- XalanDOMString theResult;
+ XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
const XalanDOMString& theArg1 = arg1->str();
const XalanDOMString& theArg2 = arg2->str();
reserve(theResult, length(theArg1) + length(theArg2) + 1);
- theResult += theArg1;
- theResult += theArg2;
+ append(theResult, theArg1);
+ append(theResult, theArg2);
return executionContext.getXObjectFactory().createString(theResult);
}
@@ -133,7 +133,7 @@
{
assert(arg1.null() == false && arg2.null() == false && arg3.null() == false);
- XalanDOMString theResult;
+ XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
const XalanDOMString& theArg1 = arg1->str();
const XalanDOMString& theArg2 = arg2->str();
@@ -141,9 +141,9 @@
reserve(theResult, length(theArg1) + length(theArg2) + length(theArg3) + 1);
- theResult += theArg1;
- theResult += theArg2;
- theResult += theArg3;
+ append(theResult, theArg1);
+ append(theResult, theArg2);
+ append(theResult, theArg3);
return executionContext.getXObjectFactory().createString(theResult);
}
@@ -172,7 +172,7 @@
}
}
- XalanDOMString theResult;
+ XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
reserve(theResult, theCombinedLength + 1);
@@ -181,7 +181,7 @@
for(; i != theEnd; ++i)
{
- theResult += (*i)->str();
+ append(theResult, (*i)->str());
}
}
1.8 +1 -1 xml-xalan/c/src/XPath/FunctionLocalName.cpp
Index: FunctionLocalName.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionLocalName.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FunctionLocalName.cpp 2000/12/06 21:00:29 1.7
+++ FunctionLocalName.cpp 2000/12/21 04:29:29 1.8
@@ -170,7 +170,7 @@
theType == XalanNode::ELEMENT_NODE ||
theType == XalanNode::PROCESSING_INSTRUCTION_NODE)
{
- return executionContext.getXObjectFactory().createString(executionContext.getLocalNameOfNode(node));
+ return executionContext.getXObjectFactory().createStringReference(executionContext.getLocalNameOfNode(node));
}
else
{
1.6 +21 -19 xml-xalan/c/src/XPath/FunctionName.cpp
Index: FunctionName.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionName.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FunctionName.cpp 2000/12/06 21:00:33 1.5
+++ FunctionName.cpp 2000/12/21 04:29:29 1.6
@@ -76,44 +76,46 @@
XObjectPtr
FunctionName::execute(
- XPathExecutionContext& executionContext,
- XalanNode* context)
+ XPathExecutionContext& executionContext,
+ XalanNode* context)
{
- XalanDOMString theData;
-
if (context == 0)
{
executionContext.error("The name() function requires a non-null context node!");
+
+ // Dummy return value...
+ return 0;
}
else
- {
- theData = executionContext.getNameOfNode(*context);
+ {
+ return executionContext.getXObjectFactory().createStringReference(executionContext.getNameOfNode(*context));
}
-
- return executionContext.getXObjectFactory().createString(theData);
}
XObjectPtr
FunctionName::execute(
- XPathExecutionContext& executionContext,
- XalanNode* /* context */,
- const XObjectPtr arg1)
+ XPathExecutionContext& executionContext,
+ XalanNode* /* context */,
+ const XObjectPtr arg1)
{
assert(arg1.null() == false);
-
- XalanDOMString theData;
const NodeRefListBase& theNodeList = arg1->nodeset();
- if (theNodeList.getLength() > 0)
+ if (theNodeList.getLength() == 0)
+ {
+ return executionContext.getXObjectFactory().createString(XalanDOMString());
+ }
+ else
{
assert(theNodeList.item(0) != 0);
- theData = executionContext.getNameOfNode(*theNodeList.item(0));
- }
+
+ const XalanDOMString& theData = executionContext.getNameOfNode(*theNodeList.item(0));
- return executionContext.getXObjectFactory().createString(theData);
+ return executionContext.getXObjectFactory().createStringReference(theData);
+ }
}
@@ -121,7 +123,7 @@
XObjectPtr
FunctionName::execute(
XPathExecutionContext& executionContext,
- XalanNode* context,
+ XalanNode* context,
const XObjectPtr /* arg1 */,
const XObjectPtr /* arg2 */)
{
@@ -135,7 +137,7 @@
XObjectPtr
FunctionName::execute(
XPathExecutionContext& executionContext,
- XalanNode* context,
+ XalanNode* context,
const XObjectPtr /* arg1 */,
const XObjectPtr /* arg2 */,
const XObjectPtr /* arg3 */)
1.7 +2 -2 xml-xalan/c/src/XPath/FunctionNamespaceURI.cpp
Index: FunctionNamespaceURI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNamespaceURI.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FunctionNamespaceURI.cpp 2000/12/06 21:00:34 1.6
+++ FunctionNamespaceURI.cpp 2000/12/21 04:29:29 1.7
@@ -91,7 +91,7 @@
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
// as the only member.
- return executionContext.getXObjectFactory().createString(executionContext.getNamespaceOfNode(*context));
+ return executionContext.getXObjectFactory().createStringReference(executionContext.getNamespaceOfNode(*context));
}
}
@@ -115,7 +115,7 @@
{
assert(theList.item(0) != 0);
- return executionContext.getXObjectFactory().createString(executionContext.getNamespaceOfNode(*theList.item(0)));
+ return executionContext.getXObjectFactory().createStringReference(executionContext.getNamespaceOfNode(*theList.item(0)));
}
}
1.8 +1 -2 xml-xalan/c/src/XPath/FunctionString.cpp
Index: FunctionString.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionString.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FunctionString.cpp 2000/12/06 21:00:52 1.7
+++ FunctionString.cpp 2000/12/21 04:29:29 1.8
@@ -117,7 +117,7 @@
{
assert(arg1.null() == false);
- return executionContext.getXObjectFactory().createString(arg1->str());
+ return executionContext.getXObjectFactory().createStringAdapter(arg1);
}
@@ -182,4 +182,3 @@
{
return XALAN_STATIC_UCODE_STRING("The string() function takes zero or one argument!");
}
-
1.10 +8 -3 xml-xalan/c/src/XPath/FunctionSubstring.cpp
Index: FunctionSubstring.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstring.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FunctionSubstring.cpp 2000/12/06 21:00:57 1.9
+++ FunctionSubstring.cpp 2000/12/21 04:29:29 1.10
@@ -252,9 +252,14 @@
theStartIndex,
theTotal);
- return executionContext.getXObjectFactory().createString(
- toCharArray(theSourceString) + theStartIndex,
- theSubstringLength);
+ XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
+
+ assign(
+ theResult,
+ toCharArray(theSourceString) + theStartIndex,
+ theSubstringLength );
+
+ return executionContext.getXObjectFactory().createString(theResult);
}
}
}
1.9 +8 -1 xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp
Index: FunctionSubstringAfter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FunctionSubstringAfter.cpp 2000/12/06 21:00:59 1.8
+++ FunctionSubstringAfter.cpp 2000/12/21 04:29:29 1.9
@@ -141,7 +141,14 @@
const unsigned int theSubstringLength =
theFirstStringLength - theIndex - theSecondStringLength;
- return executionContext.getXObjectFactory().createString(theFirstCharacter, theSubstringLength);
+ XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
+
+ assign(
+ theResult,
+ theFirstCharacter,
+ theSubstringLength);
+
+ return executionContext.getXObjectFactory().createString(theResult);
}
}
}
1.9 +7 -2 xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp
Index: FunctionSubstringBefore.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FunctionSubstringBefore.cpp 2000/12/06 21:01:01 1.8
+++ FunctionSubstringBefore.cpp 2000/12/21 04:29:29 1.9
@@ -129,10 +129,15 @@
}
else
{
- // Create a string of the appropriate length...
- return executionContext.getXObjectFactory().createString(
+ XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
+
+ assign(
+ theResult,
toCharArray(theFirstString),
theIndex);
+
+ // Create a string of the appropriate length...
+ return executionContext.getXObjectFactory().createString(theResult);
}
}
}
1.9 +6 -16 xml-xalan/c/src/XPath/FunctionTranslate.cpp
Index: FunctionTranslate.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionTranslate.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FunctionTranslate.cpp 2000/12/06 21:01:07 1.8
+++ FunctionTranslate.cpp 2000/12/21 04:29:29 1.9
@@ -137,14 +137,13 @@
typedef std::vector<XalanDOMChar> VectorType;
#endif
- // A vector to contain the new characters. We'll use it to construct
- // the result string.
- VectorType theBuffer;
+ // A string to hold the result.
+ XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
// The result string can only be as large as the first string, so
// just reserve the space now. Also reserve space for the
// terminating 0.
- theBuffer.reserve(theFirstStringLength + 1);
+ reserve(theResult, theFirstStringLength + 1);
for (unsigned int i = 0; i < theFirstStringLength; i++)
{
@@ -156,13 +155,13 @@
{
// Didn't find the character in the second string, so it
// is not translated.
- theBuffer.push_back(theCurrentChar);
+ append(theResult, theCurrentChar);
}
else if (theIndex < theThirdStringLength)
{
// OK, there's a corresponding character in the
// third string, so do the translation...
- theBuffer.push_back(charAt(theThirdString, theIndex));
+ append(theResult, charAt(theThirdString, theIndex));
}
else
{
@@ -174,16 +173,7 @@
}
}
- const VectorType::size_type theSize = theBuffer.size();
-
- if (theSize == 0)
- {
- return executionContext.getXObjectFactory().createString(XalanDOMString());
- }
- else
- {
- return executionContext.getXObjectFactory().createString(&*theBuffer.begin(), theSize);
- }
+ return executionContext.getXObjectFactory().createString(theResult);
}