From 6abba395ca46a605b62ca77f5a6994aec0b25158 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 14 Dec 2009 11:05:27 +0100 Subject: [PATCH] RemotePlugin: better code order in sendMessage() + cleanups We can cache the number of data sets in the message in order to avoid duplicate data::size() calls. Furthermore the accumulation of the size of the written data is an old relict and can be safely removed. --- include/RemotePlugin.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index 3294f54d2..1fef44622 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -922,14 +922,13 @@ RemotePluginBase::~RemotePluginBase() void RemotePluginBase::sendMessage( const message & _m ) { + const int n = _m.data.size(); m_out->lock(); m_out->writeInt( _m.id ); - m_out->writeInt( _m.data.size() ); - int j = 0; - for( unsigned int i = 0; i < _m.data.size(); ++i ) + m_out->writeInt( n ); + for( unsigned int i = 0; i < n; ++i ) { m_out->writeString( _m.data[i] ); - j += _m.data[i].size(); } m_out->unlock(); m_out->messageSent();