[Libreoffice-commits] core.git: sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Apr 6 11:17:50 UTC 2017
sw/source/filter/ww8/ww8par.cxx | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
New commits:
commit 01088af64083c706696dbfeb0c58f62bdbf84c48
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Apr 6 12:07:13 2017 +0200
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 at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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)
More information about the Libreoffice-commits
mailing list