Enable performance-no-automatic-move

Variables can be automatically moved when a function returns. However,
declaring a variable as const prevents that move from occuring (as the
move modifies the moved-from variable).
This commit is contained in:
JJ Marr 2024-09-23 09:17:29 -04:00 committed by Charles Dang
parent 15acd0c00a
commit 0b46bd3044
6 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,4 @@
---
Checks: '-*,bugprone-move-forwarding-reference,bugprone-use-after-move,cppcoreguidelines-rvalue-reference-param-not-moved,modernize-use-nullptr,performance-move-const-arg,performance-move-constructor-init,performance-unnecessary-value-param''
Checks: '-*,bugprone-move-forwarding-reference,bugprone-use-after-move,cppcoreguidelines-rvalue-reference-param-not-moved,modernize-use-nullptr,performance-move-const-arg,performance-move-constructor-init,performance-no-automatic-move,performance-unnecessary-value-param'
WarningsAsErrors: true
...

View File

@ -634,7 +634,7 @@ public:
private:
variant execute(const formula_callable& variables, formula_debugger*fdb) const
{
const variant left = left_->evaluate(variables, add_debug_info(fdb,0,"left ."));
variant left = left_->evaluate(variables, add_debug_info(fdb,0,"left ."));
if(!left.is_callable()) {
if(left.is_list()) {
list_callable list_call(left);

View File

@ -247,7 +247,7 @@ DEFINE_WFL_FUNCTION(debug_float, 2, 3)
{
const args_list& arguments = args();
const variant var0 = arguments[0]->evaluate(variables, fdb);
const variant var1 = arguments[1]->evaluate(variables, fdb);
variant var1 = arguments[1]->evaluate(variables, fdb);
const map_location location = var0.convert_to<location_callable>()->loc();
std::string text;
@ -266,7 +266,7 @@ DEFINE_WFL_FUNCTION(debug_float, 2, 3)
DEFINE_WFL_FUNCTION(debug_print, 1, 2)
{
const variant var1 = args()[0]->evaluate(variables, fdb);
variant var1 = args()[0]->evaluate(variables, fdb);
std::string str1, str2;
@ -1081,7 +1081,7 @@ DEFINE_WFL_FUNCTION(zip, 1, -1)
DEFINE_WFL_FUNCTION(reduce, 2, 3)
{
const variant items = args()[0]->evaluate(variables, fdb);
const variant initial = args().size() == 2 ? variant() : args()[1]->evaluate(variables, fdb);
variant initial = args().size() == 2 ? variant() : args()[1]->evaluate(variables, fdb);
if(items.num_elements() == 0) {
return initial;

View File

@ -215,7 +215,8 @@ static std::string generate_user_description(const config& side)
const std::string controller_type = side["controller"].str();
const std::string reservation = side["current_player"].str();
const std::string owner = side["player_id"].str();
// Making this string const means it can't be automatically moved when returned from this method
std::string owner = side["player_id"].str();
if(controller_type == side_controller::ai) {
return _("Computer Player");

View File

@ -1538,7 +1538,7 @@ void prefs::set_user_servers_list(const std::vector<game_config::server_info>& v
std::string prefs::network_host()
{
const std::string res = preferences_[prefs_list::host];
std::string res = preferences_[prefs_list::host];
if(res.empty()) {
return builtin_servers_list().front().address;
} else {

View File

@ -763,7 +763,7 @@ std::string indent(const std::string& string, std::size_t indent_size)
return string;
}
const std::string indent(indent_size, ' ');
std::string indent(indent_size, ' ');
if(string.empty()) {
return indent;