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...@apache.org on 2002/11/03 06:51:22 UTC
cvs commit: xml-xalan/c/src/XSLT StylesheetHandler.cpp StylesheetHandler.hpp
dbertoni 2002/11/02 21:51:22
Modified: c/src/XSLT StylesheetHandler.cpp StylesheetHandler.hpp
Log:
New block allocation for ElemEmpty and ElemText instances.
Revision Changes Path
1.94 +33 -12 xml-xalan/c/src/XSLT/StylesheetHandler.cpp
Index: StylesheetHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- StylesheetHandler.cpp 3 Nov 2002 03:41:06 -0000 1.93
+++ StylesheetHandler.cpp 3 Nov 2002 05:51:22 -0000 1.94
@@ -139,11 +139,13 @@
FormatterListener(OUTPUT_METHOD_OTHER),
m_stylesheet(stylesheetTree),
m_constructionContext(constructionContext),
+ m_elemEmptyAllocator(eElemEmptyAllocatorBlockSize),
+ m_elemTextAllocator(eElemTextBlockSize),
m_elemStack(),
m_elemStackParentedElements(),
m_whiteSpaceElems(),
m_pTemplate(0),
- m_lastPopped(),
+ m_lastPopped(*this),
m_inTemplate(false),
m_foundStylesheet(false),
m_foundNotImport(false),
@@ -179,8 +181,12 @@
if (j == m_elemStackParentedElements.end())
{
- // Not found, so delete it...
- delete *i;
+ if ((*i)->getXSLToken() != StylesheetConstructionContext::ELEMNAME_UNDEFINED &&
+ (*i)->getXSLToken() != StylesheetConstructionContext::ELEMNAME_TEXT)
+ {
+ // Not found, so delete it...
+ delete *i;
+ }
}
else
{
@@ -472,7 +478,7 @@
m_elemStackParentedElements.insert(foreach);
m_elemStack.push_back(
- new ElemEmpty(
+ m_elemEmptyAllocator.create(
m_constructionContext,
m_stylesheet,
&Constants::ELEMNAME_SORT_WITH_PREFIX_STRING));
@@ -631,9 +637,13 @@
break;
case StylesheetConstructionContext::ELEMNAME_TEXT:
- m_elemStack.push_back(new ElemText(m_constructionContext,
- m_stylesheet,
- atts, lineNumber, columnNumber));
+ m_elemStack.push_back(
+ m_elemTextAllocator.create(
+ m_constructionContext,
+ m_stylesheet,
+ atts,
+ lineNumber,
+ columnNumber));
break;
case StylesheetConstructionContext::ELEMNAME_ATTRIBUTE:
@@ -791,7 +801,7 @@
// object.
if(origStackSize == m_elemStack.size())
{
- m_elemStack.push_back(new ElemEmpty(m_constructionContext, m_stylesheet));
+ m_elemStack.push_back(m_elemEmptyAllocator.create(m_constructionContext, m_stylesheet));
if (elem != 0)
{
@@ -1939,7 +1949,7 @@
m_elemStack(theHandler.m_elemStack),
m_elemStackParentedElements(theHandler.m_elemStackParentedElements),
m_pTemplate(theHandler.m_pTemplate),
- m_lastPopped(),
+ m_lastPopped(theHandler),
m_inTemplate(theHandler.m_inTemplate),
m_foundStylesheet(theHandler.m_foundStylesheet),
m_XSLNameSpaceURL(theHandler.m_stylesheet.getXSLTNamespaceURI()),
@@ -2013,10 +2023,21 @@
{
const int tok = m_lastPopped->getXSLToken();
- if (tok == StylesheetConstructionContext::ELEMNAME_UNDEFINED ||
- tok == StylesheetConstructionContext::ELEMNAME_TEXT)
+ if (tok == StylesheetConstructionContext::ELEMNAME_UNDEFINED)
{
- delete m_lastPopped;
+#if defined(XALAN_OLD_STYLE_CASTS)
+ m_stylesheetHandler.m_elemEmptyAllocator.destroy((ElemEmpty*)m_lastPopped);
+#else
+ m_stylesheetHandler.m_elemEmptyAllocator.destroy(static_cast<ElemEmpty*>(m_lastPopped));
+#endif
+ }
+ else if (tok == StylesheetConstructionContext::ELEMNAME_TEXT)
+ {
+#if defined(XALAN_OLD_STYLE_CASTS)
+ m_stylesheetHandler.m_elemTextAllocator.destroy((ElemText*)m_lastPopped);
+#else
+ m_stylesheetHandler.m_elemTextAllocator.destroy(static_cast<ElemText*>(m_lastPopped));
+#endif
}
}
}
1.39 +20 -1 xml-xalan/c/src/XSLT/StylesheetHandler.hpp
Index: StylesheetHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.hpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- StylesheetHandler.hpp 3 Nov 2002 04:01:40 -0000 1.38
+++ StylesheetHandler.hpp 3 Nov 2002 05:51:22 -0000 1.39
@@ -85,6 +85,8 @@
#include <XSLT/NamespacesHandler.hpp>
#include <XSLT/Stylesheet.hpp>
+#include <XSLT/XalanElemEmptyAllocator.hpp>
+#include <XSLT/XalanElemTextAllocator.hpp>
@@ -444,6 +446,8 @@
private:
+ enum { eElemEmptyAllocatorBlockSize = 10, eElemTextBlockSize = 10 };
+
// not implemented
StylesheetHandler(const StylesheetHandler&);
@@ -584,6 +588,16 @@
StylesheetConstructionContext& m_constructionContext;
/**
+ * An allocator for ElemEmpty instances.
+ */
+ XalanElemEmptyAllocator m_elemEmptyAllocator;
+
+ /**
+ * An allocator for ElemText instances.
+ */
+ XalanElemTextAllocator m_elemTextAllocator;
+
+ /**
* The stack of elements, pushed and popped as events occur.
*/
ElemTemplateStackType m_elemStack;
@@ -611,7 +625,8 @@
{
public:
- LastPoppedHolder() :
+ LastPoppedHolder(StylesheetHandler& theStylesheetHandler) :
+ m_stylesheetHandler(theStylesheetHandler),
m_lastPopped(0)
{
}
@@ -690,8 +705,12 @@
cleanup();
// Data members...
+ StylesheetHandler& m_stylesheetHandler;
+
ElemTemplateElement* m_lastPopped;
};
+
+ friend class LastPoppedHolder;
/**
* Manages the last element popped from the stack.
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org