Use a more obscure serialize method to avoid recalculating byte size.

develop
Alexander Gavrilov 2012-03-17 17:52:23 +04:00
parent 368b92f81f
commit 3d80a1ee35
1 changed files with 3 additions and 2 deletions

@ -335,8 +335,9 @@ bool sendRemoteMessage(CSimpleSocket *socket, int16_t id, const MessageLite *msg
hdr->id = id; hdr->id = id;
hdr->size = size; hdr->size = size;
if (!msg->SerializeToArray(data.get() + sizeof(RPCMessageHeader), size)) uint8_t *pstart = data.get() + sizeof(RPCMessageHeader);
return false; uint8_t *pend = msg->SerializeWithCachedSizesToArray(pstart);
assert((pend - pstart) == size);
return (socket->Send(data.get(), fullsz) == fullsz); return (socket->Send(data.get(), fullsz) == fullsz);
} }