Optimization: use move semantics in a few more places

master
Sébastien Villemot 2022-06-13 14:15:47 +02:00
parent 8541179a56
commit ee8ee7c27f
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 39 additions and 40 deletions

View File

@ -3185,11 +3185,11 @@ DynamicModel::updateVarAndTrendModel() const
}
if (var)
var_model_table.setRhs(rhsr);
var_model_table.setRhs(move(rhsr));
else
{
trend_component_model_table.setRhs(rhsr);
trend_component_model_table.setTargetVar(trend_varr);
trend_component_model_table.setRhs(move(rhsr));
trend_component_model_table.setTargetVar(move(trend_varr));
}
}
}
@ -3256,10 +3256,10 @@ DynamicModel::fillVarModelTable() const
lhs_expr_tr[model_name] = lhs_expr_t;
rhsr[model_name] = rhs;
}
var_model_table.setEqNums(eqnums);
var_model_table.setLhs(lhsr);
var_model_table.setRhs(rhsr);
var_model_table.setLhsExprT(lhs_expr_tr);
var_model_table.setEqNums(move(eqnums));
var_model_table.setLhs(move(lhsr));
var_model_table.setRhs(move(rhsr));
var_model_table.setLhsExprT(move(lhs_expr_tr));
}
void
@ -3345,9 +3345,9 @@ DynamicModel::fillVarModelTableFromOrigModel() const
diff[model_name] = diff_vec;
orig_diff_var[model_name] = orig_diff_var_vec;
}
var_model_table.setDiff(diff);
var_model_table.setMaxLags(lags);
var_model_table.setOrigDiffVar(orig_diff_var);
var_model_table.setDiff(move(diff));
var_model_table.setMaxLags(move(lags));
var_model_table.setOrigDiffVar(move(orig_diff_var));
}
vector<int>
@ -3470,9 +3470,9 @@ DynamicModel::fillVarModelTableMatrices()
}
}
}
var_model_table.setAR(AR);
var_model_table.setA0(A0);
var_model_table.setConstants(constants);
var_model_table.setAR(move(AR));
var_model_table.setA0(move(A0));
var_model_table.setConstants(move(constants));
}
map<string, map<tuple<int, int, int>, expr_t>>
@ -3575,8 +3575,8 @@ DynamicModel::fillTrendComponentModelTable() const
lhs_expr_tr[model_name] = lhs_expr_t;
rhsr[model_name] = rhs;
}
trend_component_model_table.setRhs(rhsr);
trend_component_model_table.setVals(eqnums, trend_eqnums, lhsr, lhs_expr_tr);
trend_component_model_table.setRhs(move(rhsr));
trend_component_model_table.setVals(move(eqnums), move(trend_eqnums), move(lhsr), move(lhs_expr_tr));
}
pair<map<string, map<tuple<int, int>, expr_t>>, map<string, map<tuple<int, int>, expr_t>>>
@ -3688,18 +3688,18 @@ DynamicModel::fillTrendComponentModelTableFromOrigModel() const
diff[model_name] = diff_vec;
orig_diff_var[model_name] = orig_diff_var_vec;
}
trend_component_model_table.setDiff(diff);
trend_component_model_table.setMaxLags(lags);
trend_component_model_table.setOrigDiffVar(orig_diff_var);
trend_component_model_table.setDiff(move(diff));
trend_component_model_table.setMaxLags(move(lags));
trend_component_model_table.setOrigDiffVar(move(orig_diff_var));
}
void
DynamicModel::fillTrendComponentModelTableAREC(const ExprNode::subst_table_t &diff_subst_table) const
{
auto ARr = computeAutoregressiveMatrices();
trend_component_model_table.setAR(ARr);
trend_component_model_table.setAR(move(ARr));
auto [A0r, A0starr] = computeErrorComponentMatrices(diff_subst_table);
trend_component_model_table.setA0(A0r, A0starr);
trend_component_model_table.setA0(move(A0r), move(A0starr));
}
vector<int>

View File

@ -1513,19 +1513,19 @@ ParsingDriver::trend_component_model()
auto its = options_list.string_options.find("trend_component.name");
if (its == options_list.string_options.end())
error("You must pass the model_name option to the trend_component_model statement.");
auto name = its->second;
auto &name = its->second;
auto itvs = options_list.vector_str_options.find("trend_component.eqtags");
if (itvs == options_list.vector_str_options.end())
error("You must pass the eqtags option to the trend_component_model statement.");
auto eqtags = itvs->second;
auto &eqtags = itvs->second;
auto itvs1 = options_list.vector_str_options.find("trend_component.targets");
if (itvs1 == options_list.vector_str_options.end())
error("You must pass the targets option to the trend_component_model statement.");
auto targets = itvs1->second;
auto &targets = itvs1->second;
mod_file->trend_component_model_table.addTrendComponentModel(name, eqtags, targets);
mod_file->trend_component_model_table.addTrendComponentModel(move(name), move(eqtags), move(targets));
options_list.clear();
}
@ -1535,19 +1535,19 @@ ParsingDriver::var_model()
auto its = options_list.string_options.find("var.model_name");
if (its == options_list.string_options.end())
error("You must pass the model_name option to the var_model statement.");
auto name = its->second;
auto &name = its->second;
auto itvs = options_list.vector_str_options.find("var.eqtags");
if (itvs == options_list.vector_str_options.end())
error("You must pass the eqtags option to the var_model statement.");
auto eqtags = itvs->second;
auto &eqtags = itvs->second;
bool structural = false;
if (auto itn = options_list.num_options.find("var.structural");
itn != options_list.num_options.end() && itn->second == "true")
structural = true;
mod_file->var_model_table.addVarModel(name, structural, eqtags);
mod_file->var_model_table.addVarModel(move(name), structural, move(eqtags));
options_list.clear();
}
@ -2788,7 +2788,7 @@ ParsingDriver::pac_model()
auto it = options_list.string_options.find("pac.model_name");
if (it == options_list.string_options.end())
error("You must pass the model_name option to the pac_model statement.");
auto name = it->second;
auto &name = it->second;
string aux_model_name;
it = options_list.string_options.find("pac.aux_model_name");
@ -2798,10 +2798,10 @@ ParsingDriver::pac_model()
it = options_list.string_options.find("pac.discount");
if (it == options_list.string_options.end())
error("You must pass the discount option to the pac_model statement.");
auto discount = it->second;
auto &discount = it->second;
check_symbol_is_parameter(discount);
mod_file->pac_model_table.addPacModel(name, aux_model_name, discount, pac_growth,
mod_file->pac_model_table.addPacModel(move(name), move(aux_model_name), move(discount), pac_growth,
pac_auxname, pac_kind);
options_list.clear();
parsing_pac_model = false;
@ -3356,7 +3356,7 @@ ParsingDriver::add_moment_calibration_item(const string &endo1, const string &en
c.lower_bound = range.first;
c.upper_bound = range.second;
moment_calibration_constraints.push_back(c);
moment_calibration_constraints.push_back(move(c));
}
void
@ -3385,7 +3385,7 @@ ParsingDriver::add_irf_calibration_item(const string &endo, string periods, cons
c.lower_bound = range.first;
c.upper_bound = range.second;
irf_calibration_constraints.push_back(c);
irf_calibration_constraints.push_back(move(c));
}
void
@ -3515,7 +3515,7 @@ ParsingDriver::add_shock_group(string name)
ShockGroupsStatement::Group G;
G.name = move(name);
G.list = shock_group;
shock_groups.push_back(G);
shock_groups.push_back(move(G));
shock_group.clear();
}
@ -3566,17 +3566,17 @@ ParsingDriver::var_expectation_model()
it = options_list.string_options.find("auxiliary_model_name");
if (it == options_list.string_options.end())
error("You must pass the auxiliary_model_name option to the var_expectation_model statement.");
auto var_model_name = it->second;
auto &var_model_name = it->second;
it = options_list.string_options.find("model_name");
if (it == options_list.string_options.end())
error("You must pass the model_name option to the var_expectation_model statement.");
auto model_name = it->second;
auto &model_name = it->second;
it = options_list.num_options.find("horizon");
if (it == options_list.num_options.end())
error("You must pass the horizon option to the var_expectation_model statement.");
auto horizon = it->second;
auto &horizon = it->second;
if (var_expectation_model_discount)
{
@ -3596,8 +3596,8 @@ ParsingDriver::var_expectation_model()
if (time_shift > 0)
error("The 'time_shift' option must be a non-positive integer");
mod_file->var_expectation_model_table.addVarExpectationModel(model_name, var_expectation_model_expression,
var_model_name, horizon,
mod_file->var_expectation_model_table.addVarExpectationModel(move(model_name), var_expectation_model_expression,
move(var_model_name), move(horizon),
var_expectation_model_discount, time_shift);
options_list.clear();
@ -3692,8 +3692,7 @@ void
ParsingDriver::add_pac_target_info_component(expr_t component_expr)
{
get<0>(pac_target_info_component) = component_expr;
mod_file->pac_model_table.addTargetComponent(pac_target_info_name, pac_target_info_component);
pac_target_info_component = {};
mod_file->pac_model_table.addTargetComponent(pac_target_info_name, exchange(pac_target_info_component, {}));
}
void