bneradt commented on code in PR #13612:
URL: https://github.com/apache/trafficserver/pull/13612#discussion_r3908060174
##########
src/iocore/net/SSLSecret.cc:
##########
@@ -88,8 +88,8 @@ std::string
SSLSecret::loadFile(const std::string &name)
{
Dbg(dbg_ctl_ssl_secret, "SSLSecret::loadFile(%s)", name.c_str());
- std::error_code error;
- std::string const data = swoc::file::load(swoc::file::path(name), error);
+ std::error_code error;
+ std::string data = swoc::file::load(swoc::file::path(name), error);
Review Comment:
This is unintuitive, but the local const prevents automatic move when NRVO
is not performed: returning it produces a const std::string&&, which cannot
bind to std::string’s move constructor and therefore requires a copy. Since
data is not otherwise modified and its lifetime ends at the return, removing
const preserves the function’s semantics while allowing the fallback move. An
explicit std::move would inhibit NRVO and would not move from a const string
anyway.
--
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]