summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-09 12:35:02 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-10-09 14:58:46 +0200
commit5fcfa368d8a4aa3156674fe38365f57218a6952e (patch)
treead878c230c357be9145eaa3e6acf8a970a711d5d /sfx2
parentbcde9f1bc32ebdfdd71edd0e66502e1fcc766b18 (diff)
ofz#3577: speed up short reads
Change-Id: Ic05a7eb415ca0d3ee1cef5dcf0a881119bf52ac6 Reviewed-on: https://gerrit.libreoffice.org/43276 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/oleprops.cxx26
1 files changed, 8 insertions, 18 deletions
diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx
index 8391dede0a4b..dbf446b4a11c 100644
--- a/sfx2/source/doc/oleprops.cxx
+++ b/sfx2/source/doc/oleprops.cxx
@@ -273,13 +273,12 @@ OUString SfxOleStringHelper::ImplLoadString8( SvStream& rStrm ) const
DBG_ASSERT( (0 < nSize) && (nSize <= 0xFFFF),
OStringBuffer("SfxOleStringHelper::ImplLoadString8 - invalid string of len ").
append(nSize).getStr() );
- if( (0 < nSize) && (nSize <= 0xFFFF) )
+ if (nSize > 0 && nSize <= 0xFFFF)
{
// load character buffer
- ::std::vector< sal_Char > aBuffer( static_cast< size_t >( nSize + 1 ), 0 );
- rStrm.ReadBytes(aBuffer.data(), static_cast<std::size_t>(nSize));
- // create string from encoded character array
- aValue = OUString(aBuffer.data(), strlen(aBuffer.data()), GetTextEncoding());
+ OString sValue(read_uInt8s_ToOString(rStrm, nSize - 1));
+ rStrm.SeekRel(1); // skip null-byte at end
+ aValue = OStringToOUString(sValue, GetTextEncoding());
}
return aValue;
}
@@ -292,23 +291,14 @@ OUString SfxOleStringHelper::ImplLoadString16( SvStream& rStrm )
rStrm.ReadInt32( nSize );
DBG_ASSERT( (0 < nSize) && (nSize <= 0xFFFF), "SfxOleStringHelper::ImplLoadString16 - invalid string" );
// size field includes trailing NUL character
- if( (0 < nSize) && (nSize <= 0xFFFF) )
+ if (nSize > 0 && nSize <= 0xFFFF)
{
// load character buffer
- ::std::vector< sal_Unicode > aBuffer;
- aBuffer.reserve( static_cast< size_t >( nSize + 1 ) );
- sal_uInt16 cChar;
- for( sal_Int32 nIdx = 0; nIdx < nSize; ++nIdx )
- {
- rStrm.ReadUInt16( cChar );
- aBuffer.push_back( static_cast< sal_Unicode >( cChar ) );
- }
+ aValue = read_uInt16s_ToOUString(rStrm, nSize - 1);
+ rStrm.SeekRel(2); // skip null-byte at end
// stream is always padded to 32-bit boundary, skip 2 bytes on odd character count
if( (nSize & 1) == 1 )
- rStrm.SeekRel( 2 );
- // create string from character array
- aBuffer.push_back( 0 );
- aValue = OUString(aBuffer.data());
+ rStrm.SeekRel(2);
}
return aValue;
}