xmlhelp/source/cxxhelp/provider/inputstream.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
New commits: commit a31840be018cdc9a32f0a27e522b758cd3400b69 Author: Noel Grandin <noelgran...@gmail.com> Date: Sun Apr 3 18:02:42 2016 +0200 reduce unnecessary reallocing Change-Id: I01880cfecdab4addb358c74cbcdc02c98c0d6224 Reviewed-on: https://gerrit.libreoffice.org/23764 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noelgran...@gmail.com> diff --git a/xmlhelp/source/cxxhelp/provider/inputstream.cxx b/xmlhelp/source/cxxhelp/provider/inputstream.cxx index 36b9027..ec4f7f9 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits