dbertoni 00/06/30 14:30:31
Modified: c/src/XMLSupport FormatterToXML.cpp
Log:
Moved code to allocate buffers into constructor body so that only one of the
buffers is allocated. Decreased size of the the internal buffer, and added
code to null-terminate the buffer to make writing more efficient.
Revision Changes Path
1.20 +19 -5 xml-xalan/c/src/XMLSupport/FormatterToXML.cpp
Index: FormatterToXML.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToXML.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- FormatterToXML.cpp 2000/05/24 19:26:12 1.19
+++ FormatterToXML.cpp 2000/06/30 21:30:27 1.20
@@ -125,7 +125,7 @@
bool
FormatterToXML::s_javaEncodingIsISO = false;
-const FormatterToXML::DOMCharBufferType::size_type
FormatterToXML::s_maxBufferSize = 8 * 1024;
+const FormatterToXML::DOMCharBufferType::size_type
FormatterToXML::s_maxBufferSize = 1024;
FormatterToXML::FormatterToXML(
@@ -171,8 +171,8 @@
m_standalone(standalone),
m_mediaType(mediaType),
m_attrSpecialChars(theDefaultAttrSpecialChars),
- m_charBuf(s_maxBufferSize),
- m_byteBuf(s_maxBufferSize),
+ m_charBuf(),
+ m_byteBuf(),
m_pos(0),
m_level(0),
m_elemStack()
@@ -196,6 +196,12 @@
equals(m_encoding, s_asciiEncodingString) == true)
{
m_bytesEqualChars = true;
+
+ m_byteBuf.resize(s_maxBufferSize + 1);
+ }
+ else
+ {
+ m_charBuf.resize(s_maxBufferSize + 1);
}
#if 0
@@ -561,8 +567,12 @@
void
FormatterToXML::flushBytes()
{
- m_writer.write(&m_byteBuf[0], 0, m_pos);
+ assert(m_byteBuf.size() > 0 && m_byteBuf.size() > m_pos);
+ m_byteBuf[m_pos] = '\0';
+
+ m_writer.write(&m_byteBuf[0]);
+
m_pos = 0;
}
@@ -571,7 +581,11 @@
void
FormatterToXML::flushChars()
{
- m_writer.write(&m_charBuf[0], 0, m_pos);
+ assert(m_charBuf.size() > 0 && m_charBuf.size() > m_pos);
+
+ m_charBuf[m_pos] = 0;
+
+ m_writer.write(&m_charBuf[0]);
m_pos = 0;
}