Kaydet (Commit) 9f6e6fab authored tarafından Noel Grandin's avatar Noel Grandin

reduce unnecessary realloc'ing

Change-Id: Ic597814706573576a0ba330a69a7a38aa97e5224
Reviewed-on: https://gerrit.libreoffice.org/23694Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst e097e419
...@@ -198,13 +198,12 @@ namespace io_acceptor { ...@@ -198,13 +198,12 @@ namespace io_acceptor {
{ {
notifyListeners(this, &_started, callStarted); notifyListeners(this, &_started, callStarted);
if( aReadBytes.getLength() != nBytesToRead ) if( aReadBytes.getLength() < nBytesToRead )
{ {
aReadBytes.realloc( nBytesToRead ); aReadBytes.realloc( nBytesToRead );
} }
sal_Int32 i = 0; sal_Int32 i = m_socket.read( aReadBytes.getArray() , aReadBytes.getLength() );
i = m_socket.read( aReadBytes.getArray() , aReadBytes.getLength() );
if(i != nBytesToRead) if(i != nBytesToRead)
{ {
...@@ -220,7 +219,10 @@ namespace io_acceptor { ...@@ -220,7 +219,10 @@ namespace io_acceptor {
throw ioException; throw ioException;
} }
if( i < aReadBytes.getLength() )
{
aReadBytes.realloc( i );
}
return i; return i;
} }
else else
......
...@@ -49,11 +49,16 @@ namespace stoc_connector { ...@@ -49,11 +49,16 @@ namespace stoc_connector {
{ {
if( ! m_nStatus ) if( ! m_nStatus )
{ {
if( aReadBytes.getLength() != nBytesToRead ) if( aReadBytes.getLength() < nBytesToRead )
{ {
aReadBytes.realloc( 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 { else {
throw IOException(); throw IOException();
......
...@@ -123,7 +123,7 @@ namespace stoc_connector { ...@@ -123,7 +123,7 @@ namespace stoc_connector {
{ {
notifyListeners(this, &_started, callStarted); notifyListeners(this, &_started, callStarted);
if( aReadBytes.getLength() != nBytesToRead ) if( aReadBytes.getLength() < nBytesToRead )
{ {
aReadBytes.realloc( nBytesToRead ); aReadBytes.realloc( nBytesToRead );
} }
...@@ -143,7 +143,10 @@ namespace stoc_connector { ...@@ -143,7 +143,10 @@ namespace stoc_connector {
throw ioException; throw ioException;
} }
if( i < aReadBytes.getLength() )
{
aReadBytes.realloc( i );
}
return i; return i;
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment