Hello protobuf@,
In the code below, do we really need to use std::move() when invoking candidate_logging_context->AddFeature() ? Please see the code snippet below.
The documentation for "Arenas, Messages and Pointers" contains examples that show the use of std::move() when invoking the Movers library functions.
There are some documents for std::move() that recommend against using std::move() when returning a value. I'm pretty sure that this advice applies here, since we are passing the value to an entirely different function. The value cannot be moved, so std::move() is a no-op.
Am I misunderstanding something?
Thanks! My apologies if I have misunderstood.
void AddTagOnToAssistantLogs(
const assistant::btw::TagOn& tag_on, bool experimental,
proto2::Arena* arena, CandidateLoggingContext* candidate_logging_context) {
if (!tag_on.has_btw()) return;
const auto* ve_type = GetFeatureByBtwResponseSource(tag_on.btw().source());
auto ve = MakeArenaSafeUnique<::logs::VisualElementProto>(arena);
ve->mutable_assistant_btw_data()->set_rule_id(tag_on.btw().rule_id());
if (experimental) {
// Not logging the BTW for counterfactual triggers.
ve->set_visible(
::logs::VisualElementProto::VISIBILITY_REPRESSED_COUNTERFACTUAL);
} else if (!tag_on.btw().is_personalized_content()) {
ve->mutable_assistant_btw_data()->set_btw_text(tag_on.btw().text());
}
if (tag_on.btw().secondary_ve_source() != BtwResponseSource::UNKNOWN) {
auto secondary_ve = Copy(ve);
const auto* secondary_ve_type =
GetFeatureByBtwResponseSource(tag_on.btw().secondary_ve_source());
candidate_logging_context->AddFeature(secondary_ve_type,
std::move(secondary_ve));
}
candidate_logging_context->AddFeature(ve_type, std::move(ve));
}