BewareMyPower commented on code in PR #16969:
URL: https://github.com/apache/pulsar/pull/16969#discussion_r950085106


##########
pulsar-client-cpp/lib/MultiTopicsConsumerImpl.cc:
##########
@@ -160,7 +183,7 @@ void 
MultiTopicsConsumerImpl::subscribeTopicPartitions(const Result result,
                  (int)(conf_.getMaxTotalReceiverQueueSizeAcrossPartitions() / 
partitions)));
 
     Lock lock(mutex_);
-    topicsPartitions_.insert(std::make_pair(topicName->toString(), 
partitions));
+    topicsPartitions_.emplace(topicName->toString(), partitions);

Review Comment:
   Actually I think the existing `insert` (or the `emplace`) invocation is 
wrong.
   - `insert` or `emplace`: insert, i.e. if the key already exists, the value 
won't be updated.
   - `operator[]`: insert or update
   
   See https://en.cppreference.com/w/cpp/container/map/emplace and 
https://en.cppreference.com/w/cpp/container/map/operator_at.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to