summaryrefslogtreecommitdiff
path: root/sax/source
diff options
context:
space:
mode:
authorJörg Budischewski <jbu@openoffice.org>2002-05-15 15:33:29 +0000
committerJörg Budischewski <jbu@openoffice.org>2002-05-15 15:33:29 +0000
commit4a5ce7c5cc10c81c5bed14e537388c7b0f4cfb16 (patch)
tree6e7fe03485f152b621fcab8da54f2d0c261ae138 /sax/source
parent0645e6a1a1917fef833358f328b5d56396380698 (diff)
#97873# little performance optimization
Diffstat (limited to 'sax/source')
-rw-r--r--sax/source/expatwrap/sax_expat.cxx23
1 files changed, 13 insertions, 10 deletions
diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx
index fae657749ef6..36696db125dd 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: sax_expat.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: mtg $ $Date: 2001-11-22 13:33:28 $
+ * last change: $Author: jbu $ $Date: 2002-05-15 16:33:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,6 +58,7 @@
*
*
************************************************************************/
+#include <stdlib.h>
#include <vector>
#ifdef WIN32
@@ -81,8 +82,6 @@
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
-#include <assert.h>
-
#include "expat/xmlparse.h"
using namespace ::rtl;
@@ -102,6 +101,8 @@ using namespace ::com::sun::star::io;
namespace sax_expatwrap {
+// Useful macros for correct String conversion depending on the choosen expat-mode
+#ifdef XML_UNICODE
OUString XmlNChar2OUString( const XML_Char *p , int nLen )
{
if( p ) {
@@ -133,13 +134,11 @@ OUString XmlChar2OUString( const XML_Char *p )
}
-// Useful macros for correct String conversion depending on the choosen expat-mode
-#ifdef XML_UNICODE
#define XML_CHAR_TO_OUSTRING(x) XmlChar2OUString(x)
#define XML_CHAR_N_TO_USTRING(x,n) XmlNChar2OUString(x,n)
#else
-#define XML_CHAR_TO_OUSTRING(x) OStringToOUString(OString(x), RTL_TEXTENCODING_UTF8)
-#define XML_CHAR_N_TO_OUSTRING(x,n) OStringToOUString(OString(x,n), RTL_TEXTENCODING_UTF8 )
+#define XML_CHAR_TO_OUSTRING(x) OUString(x , strlen( x ), RTL_TEXTENCODING_UTF8)
+#define XML_CHAR_N_TO_USTRING(x,n) OUString(x,n, RTL_TEXTENCODING_UTF8 )
#endif
@@ -725,6 +724,10 @@ void SaxExpatParser_Impl::callbackStartElement( void *pvThis ,
const XML_Char *pwName ,
const XML_Char **awAttributes )
{
+ // in case of two concurrent threads, there is only the danger of an leak,
+ // which is neglectable for one string
+ static OUString g_CDATA( RTL_CONSTASCII_USTRINGPARAM( "CDATA" ) );
+
SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
if( pImpl->rDocumentHandler.is() ) {
@@ -733,10 +736,10 @@ void SaxExpatParser_Impl::callbackStartElement( void *pvThis ,
pImpl->pAttrList->clear();
while( awAttributes[i] ) {
- assert( awAttributes[i+1] );
+ OSL_ASSERT( awAttributes[i+1] );
pImpl->pAttrList->addAttribute(
XML_CHAR_TO_OUSTRING( awAttributes[i] ) ,
- OUString( RTL_CONSTASCII_USTRINGPARAM("CDATA") ) , // expat doesn't know types
+ g_CDATA , // expat doesn't know types
XML_CHAR_TO_OUSTRING( awAttributes[i+1] ) );
i +=2;
}