lizhanhui commented on code in PR #541:
URL: https://github.com/apache/rocketmq-clients/pull/541#discussion_r1349692475
##########
cpp/source/rocketmq/Producer.cpp:
##########
@@ -87,7 +87,8 @@ ProducerBuilder&
ProducerBuilder::withConfiguration(Configuration configuration)
}
ProducerBuilder& ProducerBuilder::withTopics(const std::vector<std::string>&
topics) {
- impl_->topicsOfInterest(topics);
+ auto topics_copy = topics;
Review Comment:
> The input parameter of ProducerBuilder::withTopics is a const reference,
while the input parameter of topicsOfInterest is not a constant reference. The
original approach cannot be compiled.
No, this is not true.
`ProducerImpl::topicsOfInterest(std::vector<std::string> topics)` copy happens
implicitly.
> 2. The internal implementation of topicsOfInterest will use std::
vector<>. swap(), which will cause the internal memory space held by the
incoming topics to be swapped out, which does not comply with the semantics of
read-only input parameters for withTopics.
No, it is using the implicit copy of the topics.
##########
cpp/source/rocketmq/Producer.cpp:
##########
@@ -87,7 +87,8 @@ ProducerBuilder&
ProducerBuilder::withConfiguration(Configuration configuration)
}
ProducerBuilder& ProducerBuilder::withTopics(const std::vector<std::string>&
topics) {
- impl_->topicsOfInterest(topics);
+ auto topics_copy = topics;
Review Comment:
> The input parameter of ProducerBuilder::withTopics is a const reference,
while the input parameter of topicsOfInterest is not a constant reference. The
original approach cannot be compiled.
No, this is not true.
`ProducerImpl::topicsOfInterest(std::vector<std::string> topics)` copy happens
implicitly.
> 2. The internal implementation of topicsOfInterest will use std::
vector<>. swap(), which will cause the internal memory space held by the
incoming topics to be swapped out, which does not comply with the semantics of
read-only input parameters for withTopics.
No, it is using the implicit copy of the topics.
--
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]