Copilot commented on code in PR #13904:
URL: https://github.com/apache/trafficserver/pull/13904#discussion_r4376415608


##########
src/mgmt/config/ConfigContext.cc:
##########
@@ -168,7 +175,10 @@ ConfigContext::add_dependent_ctx(std::string_view 
description, std::string_view
 void
 ConfigContext::set_supplied_yaml(YAML::Node node)
 {
-  _supplied_yaml = node; // YAML::Node has no move semantics; copy is cheap 
(ref-counted).
+  auto next = _payload ? std::make_shared<Payload>(*_payload) : 
std::make_shared<Payload>();
+  // emplace() copy-constructs the node; assigning into an engaged optional 
would write through.
+  next->supplied_yaml.emplace(node); // YAML::Node has no move semantics; copy 
is cheap (ref-counted).

Review Comment:
   The inline comment says `YAML::Node` has no move semantics, but yaml-cpp's 
`Node` provides a move constructor. The `node` parameter is taken by value and 
is not used afterward, so `emplace(std::move(node))` avoids an extra 
reference-count increment. Update the comment to match, for example by noting 
that the node is moved into the payload. This is optional, since the current 
copy is functionally correct.



-- 
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