From 0afb7f4eeaa75bf380721c28d9bfeedfa511d76a Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 9 Mar 2014 11:24:13 +0400 Subject: [PATCH] Minor optimization for publisher --- libuavcan/include/uavcan/publisher.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libuavcan/include/uavcan/publisher.hpp b/libuavcan/include/uavcan/publisher.hpp index 02516b7ada..aa046cf18b 100644 --- a/libuavcan/include/uavcan/publisher.hpp +++ b/libuavcan/include/uavcan/publisher.hpp @@ -69,15 +69,16 @@ private: if (!buf) return -1; - BitStream bitstream(*buf); - ScalarCodec codec(bitstream); - const int encode_res = DataType::encode(message, codec); - if (encode_res <= 0) { - assert(0); // Impossible, internal error - return -1; + BitStream bitstream(*buf); + ScalarCodec codec(bitstream); + const int encode_res = DataType::encode(message, codec); + if (encode_res <= 0) + { + assert(0); // Impossible, internal error + return -1; + } } - return sender_->send(buf->getDataPtr(), buf->getDataLength(), getTxDeadline(), monotonic_blocking_deadline, transfer_type, dst_node_id); }