From 21eef3b4b0e7a1a1b1b3ce8a63eb6352f5eb6e62 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 3 Apr 2016 17:22:48 +0200 Subject: unnecessary realloc Change-Id: Iafd6495a8b6a2b371cf004e4383ed92ac6ae4bd2 Reviewed-on: https://gerrit.libreoffice.org/23760 Tested-by: Jenkins Reviewed-by: Noel Grandin --- ucb/source/ucp/package/pkgcontent.cxx | 9 ++++----- ucb/source/ucp/tdoc/tdoc_content.cxx | 17 ++++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx index e90152f5de8d..09975a7ce3ce 100644 --- a/ucb/source/ucp/package/pkgcontent.cxx +++ b/ucb/source/ucp/package/pkgcontent.cxx @@ -1489,14 +1489,13 @@ uno::Any Content::open( try { uno::Sequence< sal_Int8 > aBuffer; - sal_Int32 nRead = xIn->readSomeBytes( aBuffer, 65536 ); - - while ( nRead > 0 ) + while (true) { + sal_Int32 nRead = xIn->readSomeBytes( aBuffer, 65536 ); + if (!nRead) + break; aBuffer.realloc( nRead ); xOut->writeBytes( aBuffer ); - aBuffer.realloc( 0 ); - nRead = xIn->readSomeBytes( aBuffer, 65536 ); } xOut->closeOutput(); diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx index 08895cfae8ca..a5b7a0d539c6 100644 --- a/ucb/source/ucp/tdoc/tdoc_content.cxx +++ b/ucb/source/ucp/tdoc/tdoc_content.cxx @@ -1484,14 +1484,14 @@ uno::Any Content::open( try { uno::Sequence< sal_Int8 > aBuffer; - sal_Int32 nRead = xIn->readSomeBytes( aBuffer, 65536 ); - while ( nRead > 0 ) + while (true) { + sal_Int32 nRead = xIn->readSomeBytes( aBuffer, 65536 ); + if (!nRead) + break; aBuffer.realloc( nRead ); xOut->writeBytes( aBuffer ); - aBuffer.realloc( 0 ); - nRead = xIn->readSomeBytes( aBuffer, 65536 ); } xOut->closeOutput(); @@ -2417,14 +2417,13 @@ bool Content::storeData( const uno::Reference< io::XInputStream >& xData, try { uno::Sequence< sal_Int8 > aBuffer; - sal_Int32 nRead = xData->readSomeBytes( aBuffer, 65536 ); - - while ( nRead > 0 ) + while (true) { + sal_Int32 nRead = xData->readSomeBytes( aBuffer, 65536 ); + if (!nRead) + break; aBuffer.realloc( nRead ); xOut->writeBytes( aBuffer ); - aBuffer.realloc( 0 ); - nRead = xData->readSomeBytes( aBuffer, 65536 ); } closeOutputStream( xOut ); -- cgit