From 3d80a1ee35be9dcff1e53f74e5be3581c0d42743 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 17 Mar 2012 17:52:23 +0400 Subject: [PATCH] Use a more obscure serialize method to avoid recalculating byte size. --- library/RemoteClient.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/RemoteClient.cpp b/library/RemoteClient.cpp index a66421aa0..a1ac2ec92 100644 --- a/library/RemoteClient.cpp +++ b/library/RemoteClient.cpp @@ -335,8 +335,9 @@ bool sendRemoteMessage(CSimpleSocket *socket, int16_t id, const MessageLite *msg hdr->id = id; hdr->size = size; - if (!msg->SerializeToArray(data.get() + sizeof(RPCMessageHeader), size)) - return false; + uint8_t *pstart = data.get() + sizeof(RPCMessageHeader); + uint8_t *pend = msg->SerializeWithCachedSizesToArray(pstart); + assert((pend - pstart) == size); return (socket->Send(data.get(), fullsz) == fullsz); }