diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2016-04-03 18:02:42 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-04-04 09:19:15 +0000 |
commit | a31840be018cdc9a32f0a27e522b758cd3400b69 (patch) | |
tree | 98d2eab3c89301c6ab42fe99bbb4a072abfd057e /xmlhelp | |
parent | sequence->vector in vcl (diff) | |
download | core-a31840be018cdc9a32f0a27e522b758cd3400b69.tar.gz core-a31840be018cdc9a32f0a27e522b758cd3400b69.zip |
reduce unnecessary reallocing
Change-Id: I01880cfecdab4addb358c74cbcdc02c98c0d6224
Reviewed-on: https://gerrit.libreoffice.org/23764
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'xmlhelp')
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/inputstream.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/inputstream.cxx b/xmlhelp/source/cxxhelp/provider/inputstream.cxx index 36b902768100..ec4f7f97fdfa 100644 --- a/xmlhelp/source/cxxhelp/provider/inputstream.cxx +++ b/xmlhelp/source/cxxhelp/provider/inputstream.cxx @@ -84,19 +84,20 @@ XInputStream_impl::readBytes( if( ! m_bIsOpen ) throw io::IOException(); - aData.realloc(nBytesToRead); + if (aData.getLength() < nBytesToRead) + aData.realloc(nBytesToRead); //TODO! translate memory exhaustion (if it were detectable...) into // io::BufferSizeExceededException - sal_uInt64 nrc; - m_aFile.read( aData.getArray(),sal_uInt64(nBytesToRead),nrc ); + sal_uInt64 nBytesRead; + m_aFile.read( aData.getArray(), sal_uInt64(nBytesToRead), nBytesRead ); // Shrink aData in case we read less than nBytesToRead (XInputStream // documentation does not tell whether this is required, and I do not know // if any code relies on this, so be conservative---SB): - if (nrc != sal::static_int_cast<sal_uInt64>( nBytesToRead) ) - aData.realloc(sal_Int32(nrc)); - return ( sal_Int32 ) nrc; + if (nBytesRead != sal::static_int_cast<sal_uInt64>(nBytesToRead) ) + aData.realloc(sal_Int32(nBytesRead)); + return ( sal_Int32 ) nBytesRead; } sal_Int32 SAL_CALL |