Skip to content

Commit ceee045

Browse files
committed
coverity: move instead of copy
1 parent e008244 commit ceee045

19 files changed

Lines changed: 50 additions & 50 deletions

File tree

code/controlconfig/controlsconfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ bool control_config_accept(bool API_Access)
13481348

13491349
// Pack the current bindings into a preset, then save the file
13501350
CC_preset preset;
1351-
preset.name = str;
1351+
preset.name = std::move(str);
13521352
std::copy(Control_config.begin(), Control_config.end(), std::back_inserter(preset.bindings));
13531353
Control_config_presets.push_back(preset);
13541354
save_preset_file(preset, true);

code/hud/hudsquadmsg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void hud_squadmsg_start()
207207
auto paramList = scripting::hook_param_list(scripting::hook_param("Player", 'o', Player_obj));
208208
if (scripting::hooks::OnHudCommMenuOpened->isOverride(paramList))
209209
{
210-
scripting::hooks::OnHudCommMenuOpened->run(paramList);
210+
scripting::hooks::OnHudCommMenuOpened->run(std::move(paramList));
211211
return;
212212
}
213213
}
@@ -243,7 +243,7 @@ void hud_squadmsg_end()
243243
auto paramList = scripting::hook_param_list(scripting::hook_param("Player", 'o', Player_obj));
244244
if (scripting::hooks::OnHudCommMenuClosed->isOverride(paramList))
245245
{
246-
scripting::hooks::OnHudCommMenuClosed->run(paramList);
246+
scripting::hooks::OnHudCommMenuClosed->run(std::move(paramList));
247247
return;
248248
}
249249
}
@@ -2007,7 +2007,7 @@ void hud_squadmsg_reinforcement_select()
20072007
}
20082008

20092009
Assert ( Num_menu_items < MAX_MENU_ITEMS );
2010-
MsgItems[Num_menu_items].text = rp_name;
2010+
MsgItems[Num_menu_items].text = std::move(rp_name);
20112011
MsgItems[Num_menu_items].instance = i;
20122012
MsgItems[Num_menu_items].active = 0;
20132013

code/model/animation/modelanimation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ namespace animation {
10841084
return submodel;
10851085
}
10861086

1087-
auto submodel = std::shared_ptr<ModelAnimationSubmodel>(new ModelAnimationSubmodel(submodelName));
1087+
auto submodel = std::make_shared<ModelAnimationSubmodel>(std::move(submodelName));
10881088
m_submodels.push_back(submodel);
10891089
return submodel;
10901090
}
@@ -1100,7 +1100,7 @@ namespace animation {
11001100
}
11011101
}
11021102

1103-
auto submodel = std::shared_ptr<ModelAnimationSubmodelTurret>(new ModelAnimationSubmodelTurret(submodelName, findBarrel, SIP_name));
1103+
auto submodel = std::make_shared<ModelAnimationSubmodelTurret>(std::move(submodelName), findBarrel, SIP_name);
11041104
m_submodels.push_back(submodel);
11051105
return submodel;
11061106
}
@@ -1360,7 +1360,7 @@ namespace animation {
13601360

13611361
animation->setAnimation(helper.parseSegment());
13621362

1363-
s_animationsById.emplace(helper.m_animationName, ParsedModelAnimation { animation, type, name, subtype });
1363+
s_animationsById.emplace(helper.m_animationName, ParsedModelAnimation { std::move(animation), type, std::move(name), subtype });
13641364
}
13651365

13661366
void ModelAnimationParseHelper::parseSingleMoveable() {
@@ -1699,7 +1699,7 @@ namespace animation {
16991699
}
17001700
else {
17011701
auto subsys = sip->animations.getSubmodel(sp->subobj_name);
1702-
auto rot = std::shared_ptr<ModelAnimationSegmentSetOrientation>(new ModelAnimationSegmentSetOrientation(subsys, angle, isRelative ? ModelAnimationCoordinateRelation::RELATIVE_COORDS : ModelAnimationCoordinateRelation::ABSOLUTE_COORDS));
1702+
auto rot = std::make_shared<ModelAnimationSegmentSetOrientation>(std::move(subsys), angle, isRelative ? ModelAnimationCoordinateRelation::RELATIVE_COORDS : ModelAnimationCoordinateRelation::ABSOLUTE_COORDS);
17031703
anim->setAnimation(std::move(rot));
17041704
}
17051705

code/model/animation/modelanimation_moveables.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace animation {
178178

179179
auto sequence = std::shared_ptr<ModelAnimationSegmentSerial>(new ModelAnimationSegmentSerial());
180180
sequence->addSegment(std::shared_ptr<ModelAnimationSegment>(new ModelAnimationSegmentSetOffset(submodel, m_defaultOffset, ModelAnimationCoordinateRelation::RELATIVE_COORDS)));
181-
sequence->addSegment(std::shared_ptr<ModelAnimationSegment>(new ModelAnimationSegmentTranslation(submodel, m_defaultOffset, m_velocity, std::nullopt, m_acceleration, ModelAnimationSegmentTranslation::CoordinateSystem::COORDS_PARENT, ModelAnimationCoordinateRelation::ABSOLUTE_COORDS)));
181+
sequence->addSegment(std::shared_ptr<ModelAnimationSegment>(new ModelAnimationSegmentTranslation(std::move(submodel), m_defaultOffset, m_velocity, std::nullopt, m_acceleration, ModelAnimationSegmentTranslation::CoordinateSystem::COORDS_PARENT, ModelAnimationCoordinateRelation::ABSOLUTE_COORDS)));
182182

183183
anim->setAnimation(sequence);
184184

@@ -377,7 +377,7 @@ namespace animation {
377377
auto submodel = parentSet->getSubmodel(link.submodel);
378378
auto rotation = std::make_shared<ModelAnimationSegmentRotation>(submodel, std::optional<angles>({0,0,0}), std::nullopt, m_time, link.acceleration, ModelAnimationCoordinateRelation::ABSOLUTE_COORDS);
379379
parallelIK->addSegment(rotation);
380-
segment->m_chain.push_back({submodel, link.constraint, rotation});
380+
segment->m_chain.push_back({submodel, link.constraint, std::move(rotation)});
381381
}
382382

383383
sequence->addSegment(segment);
@@ -432,7 +432,7 @@ namespace animation {
432432
} else
433433
constraint = std::shared_ptr<ik_constraint>(new ik_constraint());
434434

435-
chain.push_back({submodel, constraint, acceleration});
435+
chain.push_back({std::move(submodel), constraint, acceleration});
436436
}
437437

438438
return std::shared_ptr<ModelAnimationMoveable>(new ModelAnimationMoveableIK(chain, time));

code/network/psnet2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ static bool psnet_explode_ip_string(const char *ip_string, SCP_string &host, SCP
11011101
host = ip.substr(0, colon);
11021102
port = ip.substr(colon + 1);
11031103
} else {
1104-
host = ip;
1104+
host = std::move(ip);
11051105
}
11061106

11071107
return true;

code/parse/sexp/LuaSEXP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ void LuaSEXP::parseTable() {
733733

734734
if (new_enum) {
735735
type.second = increment_enum_list_id();
736-
Dynamic_enums.push_back(thisList);
736+
Dynamic_enums.push_back(std::move(thisList));
737737
} else {
738738
// Not an error but large mods may lose track of their enum names and I thought this would be helpful -Mjn
739739
mprintf(("Found previously existing Lua Enum '%s'. Using that for sexp '%s'!\n",

code/parse/sexp/sexp_lookup.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void parse_sexp_table(const char* filename) {
9292
}
9393

9494
if (thisList.list.size() > 0) {
95-
Dynamic_enums.push_back(thisList);
95+
Dynamic_enums.push_back(std::move(thisList));
9696
increment_enum_list_id();
9797
} else {
9898
error_display(0, "Parsed empty enum list '%s'. Ignoring!\n", thisList.name.c_str());
@@ -244,8 +244,8 @@ int add_dynamic_sexp(std::unique_ptr<DynamicSEXP>&& sexp, sexp_oper_type type)
244244
global.operator_const_mapping.insert(std::make_pair(new_op.value, std::move(sexp)));
245245

246246
// Now actually add the operator to the SEXP containers
247-
Operators.push_back(new_op);
248-
Sexp_help.push_back(new_help);
247+
Operators.push_back(std::move(new_op));
248+
Sexp_help.push_back(std::move(new_help));
249249

250250
return new_op.value;
251251
}

code/pilotfile/plr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ void pilotfile::plr_reset_data(bool reset_all)
10351035
scoring_special_t blank_score;
10361036

10371037
all_time_stats = blank_score;
1038-
multi_stats = blank_score;
1038+
multi_stats = std::move(blank_score);
10391039

10401040
// clear variables
10411041
p->variables.clear();

code/popup/popup.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ int popup_init(popup_info *pi, int flags)
533533
scripting::hook_param("AllowedInput", 's', pi->valid_chars, flags & PF_INPUT));
534534

535535
scripting::hooks::OnDialogInit->run(paramList);
536-
if (scripting::hooks::OnDialogInit->isOverride(paramList))
536+
if (scripting::hooks::OnDialogInit->isOverride(std::move(paramList)))
537537
return 0;
538538
}
539539

@@ -954,7 +954,7 @@ int popup_do(popup_info *pi, int flags)
954954
scripting::hook_param("IsDeathPopup", 'b', false));
955955

956956
scripting::hooks::OnDialogFrame->run(paramList);
957-
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(paramList);
957+
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(std::move(paramList));
958958
}
959959

960960
if (!isScriptingOverride) {
@@ -1025,7 +1025,7 @@ int popup_do_with_condition(popup_info *pi, int flags, int(*condition)())
10251025
scripting::hook_param("Text", 's', pi->raw_text));
10261026

10271027
scripting::hooks::OnDialogFrame->run(paramList);
1028-
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(paramList);
1028+
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(std::move(paramList));
10291029
gr_flip();
10301030
}
10311031

@@ -1398,7 +1398,7 @@ int popup_conditional_do(int (*condition)(), const char *text)
13981398
scripting::hook_param("Text", 's', pi->raw_text));
13991399

14001400
scripting::hooks::OnDialogFrame->run(paramList);
1401-
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(paramList);
1401+
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(std::move(paramList));
14021402
gr_flip();
14031403
}
14041404

code/popup/popupdead.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void popupdead_start()
244244
scripting::hook_param("DeathMessage", 's', Player->death_message.c_str()));
245245

246246
scripting::hooks::OnDialogInit->run(paramList);
247-
if (scripting::hooks::OnDialogInit->isOverride(paramList))
247+
if (scripting::hooks::OnDialogInit->isOverride(std::move(paramList)))
248248
return;
249249
}
250250

@@ -496,7 +496,7 @@ int popupdead_do_frame(float /*frametime*/)
496496
scripting::hook_param("Freeze", 'b', static_cast<bool>(popup_active())));
497497

498498
scripting::hooks::OnDialogFrame->run(paramList);
499-
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(paramList);
499+
isScriptingOverride = scripting::hooks::OnDialogFrame->isOverride(std::move(paramList));
500500
}
501501

502502
// don't process keys/buttons if another popup is active

0 commit comments

Comments
 (0)