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 {
{
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
......
......@@ -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();
......
......@@ -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
......
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