[Libreoffice-commits] core.git: io/source
Noel Grandin
noelgrandin at gmail.com
Fri Apr 1 07:32:51 UTC 2016
io/source/acceptor/acc_socket.cxx | 10 ++++++----
io/source/connector/ctr_pipe.cxx | 9 +++++++--
io/source/connector/ctr_socket.cxx | 7 +++++--
3 files changed, 18 insertions(+), 8 deletions(-)
New commits:
commit 9f6e6fabcd5718e0b65437c5ce398e520f47aae1
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sun Feb 21 14:15:39 2016 +0200
reduce unnecessary realloc'ing
Change-Id: Ic597814706573576a0ba330a69a7a38aa97e5224
Reviewed-on: https://gerrit.libreoffice.org/23694
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/io/source/acceptor/acc_socket.cxx b/io/source/acceptor/acc_socket.cxx
index b1a30a1..3fe29f3 100644
--- a/io/source/acceptor/acc_socket.cxx
+++ b/io/source/acceptor/acc_socket.cxx
@@ -198,13 +198,12 @@ namespace io_acceptor {
{
notifyListeners(this, &_started, callStarted);
- if( aReadBytes.getLength() != nBytesToRead )
+ if( aReadBytes.getLength() < nBytesToRead )
{
aReadBytes.realloc( nBytesToRead );
}
- sal_Int32 i = 0;
- i = m_socket.read( aReadBytes.getArray() , aReadBytes.getLength() );
+ sal_Int32 i = m_socket.read( aReadBytes.getArray() , aReadBytes.getLength() );
if(i != nBytesToRead)
{
@@ -220,7 +219,10 @@ namespace io_acceptor {
throw ioException;
}
-
+ if( i < aReadBytes.getLength() )
+ {
+ aReadBytes.realloc( i );
+ }
return i;
}
else
diff --git a/io/source/connector/ctr_pipe.cxx b/io/source/connector/ctr_pipe.cxx
index df15291..dafdc42 100644
--- a/io/source/connector/ctr_pipe.cxx
+++ b/io/source/connector/ctr_pipe.cxx
@@ -49,11 +49,16 @@ namespace stoc_connector {
{
if( ! m_nStatus )
{
- if( aReadBytes.getLength() != nBytesToRead )
+ if( aReadBytes.getLength() < nBytesToRead )
{
aReadBytes.realloc( nBytesToRead );
}
- return m_pipe.read( aReadBytes.getArray() , aReadBytes.getLength() );
+ sal_Int32 n = m_pipe.read( aReadBytes.getArray() , aReadBytes.getLength() );
+ if( n < aReadBytes.getLength() )
+ {
+ aReadBytes.realloc( n );
+ }
+ return n;
}
else {
throw IOException();
diff --git a/io/source/connector/ctr_socket.cxx b/io/source/connector/ctr_socket.cxx
index 2c0d3f6..787a470 100644
--- a/io/source/connector/ctr_socket.cxx
+++ b/io/source/connector/ctr_socket.cxx
@@ -123,7 +123,7 @@ namespace stoc_connector {
{
notifyListeners(this, &_started, callStarted);
- if( aReadBytes.getLength() != nBytesToRead )
+ if( aReadBytes.getLength() < nBytesToRead )
{
aReadBytes.realloc( nBytesToRead );
}
@@ -143,7 +143,10 @@ namespace stoc_connector {
throw ioException;
}
-
+ if( i < aReadBytes.getLength() )
+ {
+ aReadBytes.realloc( i );
+ }
return i;
}
else
More information about the Libreoffice-commits
mailing list