mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-02 19:47:55 +00:00
Merge pull request #40 from arvidn/poll-batch-performance
improve performance of Consumer::poll_batch()
This commit is contained in:
@@ -214,12 +214,14 @@ vector<Message> Consumer::poll_batch(size_t max_batch_size, milliseconds timeout
|
|||||||
raw_messages.size());
|
raw_messages.size());
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
check_error(rd_kafka_last_error());
|
check_error(rd_kafka_last_error());
|
||||||
|
// on the off-chance that check_error() does not throw an error
|
||||||
|
result = 0;
|
||||||
}
|
}
|
||||||
vector<Message> output;
|
vector<Message> output;
|
||||||
|
raw_messages.resize(result);
|
||||||
|
output.reserve(result);
|
||||||
for (const auto ptr : raw_messages) {
|
for (const auto ptr : raw_messages) {
|
||||||
if (ptr) {
|
output.emplace_back(ptr);
|
||||||
output.emplace_back(ptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user