[Libreoffice-commits] core.git: xmlhelp/source

Noel Grandin noelgrandin at gmail.com
Mon Apr 4 09:19:38 UTC 2016


 xmlhelp/source/cxxhelp/provider/inputstream.cxx |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit a31840be018cdc9a32f0a27e522b758cd3400b69
Author: Noel Grandin <noelgrandin at 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 <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at 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


More information about the Libreoffice-commits mailing list