Open
Description
#include <string>
class A
{
public:
A(std::string s)
: s_(std::move(s))
{}
private:
std::string s_;
};
extern void f1(std::string s) {
A a{s}; // performance-unnecessary-value-param
}
extern void f3(std::string s) {
if (!s.empty()) // performance-unnecessary-value-param
{
A a{s}; // no warning
}
}
<source>:14:6: warning: parameter 's' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
A a{s}; // performance-unnecessary-value-param
^
std::move( )
<source>:17:28: warning: the parameter 's' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
extern void f3(std::string s) {
^
const &