diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-06 12:07:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-06 11:17:20 +0000 |
commit | 01088af64083c706696dbfeb0c58f62bdbf84c48 (patch) | |
tree | d426101b23cbc78be0e3b918fe4894c4e43ce482 | |
parent | 68d5dbf34d88a9029b15010115c502b3dc7095c8 (diff) |
SwWW8ImplReader::ReadRawUniString needs some love
- remove the useless null substition
- remove a copy by reading directly a rtl_uString object
Change-Id: Ifa02bcee0ec1d119d8ff4da34788f13f58873c93
Reviewed-on: https://gerrit.libreoffice.org/36199
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index beb35144f743..af6984e73c48 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -214,16 +214,10 @@ void lclIgnoreString32( SvMemoryStream& rStrm, bool b16Bit ) OUString SwWW8ImplReader::ReadRawUniString(SvMemoryStream& rStrm, sal_uInt16 nChars, bool b16Bit) { - // Fixed-size characters - const sal_uInt8 WW8_NUL_C = '\x00'; /// NUL chararcter. - const sal_uInt16 WW8_NUL = WW8_NUL_C; /// NUL chararcter (unicode). - sal_Unicode mcNulSubst = '\0'; + rtl_uString *pStr = rtl_uString_alloc(nChars); - sal_uInt16 nCharsLeft = nChars; - std::unique_ptr<sal_Unicode[]> pcBuffer( new sal_Unicode[ nCharsLeft + 1 ] ); - - sal_Unicode* pcUniChar = pcBuffer.get(); - sal_Unicode* pcEndChar = pcBuffer.get() + nCharsLeft; + sal_Unicode* pcUniChar = pStr->buffer; + sal_Unicode* pcEndChar = pStr->buffer + nChars; if( b16Bit ) { @@ -231,7 +225,7 @@ OUString SwWW8ImplReader::ReadRawUniString(SvMemoryStream& rStrm, sal_uInt16 nCh for( ; (pcUniChar < pcEndChar); ++pcUniChar ) { rStrm.ReadUInt16( nReadChar ); - (*pcUniChar) = (nReadChar == WW8_NUL) ? mcNulSubst : static_cast< sal_Unicode >( nReadChar ); + (*pcUniChar) = static_cast< sal_Unicode >( nReadChar ); } } else @@ -240,13 +234,11 @@ OUString SwWW8ImplReader::ReadRawUniString(SvMemoryStream& rStrm, sal_uInt16 nCh for( ; (pcUniChar < pcEndChar); ++pcUniChar ) { rStrm.ReadUChar( nReadChar ) ; - (*pcUniChar) = (nReadChar == WW8_NUL_C) ? mcNulSubst : static_cast< sal_Unicode >( nReadChar ); + (*pcUniChar) = static_cast< sal_Unicode >( nReadChar ); } } - *pcEndChar = '\0'; - OUString aRet(pcBuffer.get()); - return aRet; + return OUString(pStr, SAL_NO_ACQUIRE); } void lclAppendString32(OUString& rString, SvMemoryStream& rStrm, sal_uInt32 nChars, bool b16Bit) |