diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-03 16:37:26 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-23 14:30:29 +0200 |
commit | d958e6d04983eb395b13b0d72aae5af550f9db9f (patch) | |
tree | 6939f361bd80c1575fe56eeb5ba3a18c68ce5ea5 /sax | |
parent | f89cace61aebe2d567ea3bd0dfb89cb04f3490c2 (diff) |
FastSerializer: Simplify OUString write a bit more
Change-Id: Ifa0746d635ec43cdc37867cf94bcc128bb8e2aca
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index cd8b0caed9c4..0f05ec9a3ff0 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -53,15 +53,6 @@ static const char sEqualSignAndQuote[] = "=\""; static const char sSpace[] = " "; static const char sXmlHeader[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; -static bool lcl_isAscii(const OUString& sStr) -{ - for (sal_Int32 i = 0; i < sStr.getLength(); ++i) - if (sStr[i] & 0xff80) - return false; - - return true; -} - namespace sax_fastparser { FastSaxSerializer::FastSaxSerializer( const css::uno::Reference< css::io::XOutputStream >& xOutputStream ) : maCachedOutputStream() @@ -101,16 +92,16 @@ namespace sax_fastparser { void FastSaxSerializer::write( const OUString& sOutput, bool bEscape ) { - if (!lcl_isAscii(sOutput)) - { - write( OUStringToOString(sOutput, RTL_TEXTENCODING_UTF8), bEscape ); - return ; - } - - for (sal_Int32 i = 0; i < sOutput.getLength(); ++i) + const sal_Int32 nLength = sOutput.getLength(); + for (sal_Int32 i = 0; i < nLength; ++i) { - char c = sOutput[ i ]; - if (bEscape) switch( c ) + const sal_Unicode cUnicode = sOutput[ i ]; + const char cChar = cUnicode; + if (cUnicode & 0xff80) + { + write( OString(&cUnicode, 1, RTL_TEXTENCODING_UTF8) ); + } + else if(bEscape) switch( cChar ) { case '<': writeBytes( "<", 4 ); break; case '>': writeBytes( ">", 4 ); break; @@ -119,10 +110,10 @@ namespace sax_fastparser { case '"': writeBytes( """, 6 ); break; case '\n': writeBytes( " ", 5 ); break; case '\r': writeBytes( " ", 5 ); break; - default: writeBytes( &c, 1 ); break; + default: writeBytes( &cChar, 1 ); break; } else - writeBytes( &c, 1 ); + writeBytes( &cChar, 1 ); } } |