You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by if...@apache.org on 2020/05/26 23:17:19 UTC
[rocketmq-client-cpp] 02/02: fixed uniqMsgId for batch result.
This is an automated email from the ASF dual-hosted git repository.
ifplusor pushed a commit to branch re_dev
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git
commit 7eef63909442d1b522fce2170f9f10c746292199
Author: James Yin <yw...@hotmail.com>
AuthorDate: Mon May 18 11:23:35 2020 +0800
fixed uniqMsgId for batch result.
---
src/MQClientAPIImpl.cpp | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/MQClientAPIImpl.cpp b/src/MQClientAPIImpl.cpp
index 53da586..23fea6a 100644
--- a/src/MQClientAPIImpl.cpp
+++ b/src/MQClientAPIImpl.cpp
@@ -219,14 +219,13 @@ SendResult* MQClientAPIImpl::processSendResponse(const std::string& brokerName,
if (msg->isBatch()) {
const auto& messages = static_cast<const MessageBatch*>(msg)->getMessages();
uniqMsgId.clear();
- uniqMsgId.reserve(33 * messages.size());
- bool isFirst = true;
+ uniqMsgId.reserve(33 * messages.size() + 1);
for (const auto& message : messages) {
- if (!isFirst) {
- uniqMsgId.append(",");
- isFirst = false;
- }
uniqMsgId.append(MessageClientIDSetter::getUniqID(*message));
+ uniqMsgId.append(",");
+ }
+ if (!uniqMsgId.empty()) {
+ uniqMsgId.resize(uniqMsgId.length() - 1);
}
}