Verified Commit 176732ee authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

ModelTree: pass argument by const-reference rather than by value in some methods

parent 17c41042
Pipeline #1505 passed with stage
in 1 minute and 53 seconds
......@@ -1965,29 +1965,23 @@ ModelTree::addAuxEquation(expr_t eq)
}
void
ModelTree::addTrendVariables(vector<int> trend_vars, expr_t growth_factor) noexcept(false)
ModelTree::addTrendVariables(const vector<int> &trend_vars, expr_t growth_factor) noexcept(false)
{
while (!trend_vars.empty())
if (trend_symbols_map.find(trend_vars.back()) != trend_symbols_map.end())
throw TrendException(symbol_table.getName(trend_vars.back()));
for (int id : trend_vars)
if (trend_symbols_map.find(id) != trend_symbols_map.end())
throw TrendException(symbol_table.getName(id));
else
{
trend_symbols_map[trend_vars.back()] = growth_factor;
trend_vars.pop_back();
}
trend_symbols_map[id] = growth_factor;
}
void
ModelTree::addNonstationaryVariables(vector<int> nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false)
ModelTree::addNonstationaryVariables(const vector<int> &nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false)
{
while (!nonstationary_vars.empty())
if (nonstationary_symbols_map.find(nonstationary_vars.back()) != nonstationary_symbols_map.end())
throw TrendException(symbol_table.getName(nonstationary_vars.back()));
for (int id : nonstationary_vars)
if (nonstationary_symbols_map.find(id) != nonstationary_symbols_map.end())
throw TrendException(symbol_table.getName(id));
else
{
nonstationary_symbols_map[nonstationary_vars.back()] = { log_deflator, deflator };
nonstationary_vars.pop_back();
}
nonstationary_symbols_map[id] = { log_deflator, deflator };
}
void
......
......@@ -343,9 +343,9 @@ public:
//! Returns the number of equations in the model
int equation_number() const;
//! Adds a trend variable with its growth factor
void addTrendVariables(vector<int> trend_vars, expr_t growth_factor) noexcept(false);
void addTrendVariables(const vector<int> &trend_vars, expr_t growth_factor) noexcept(false);
//! Adds a nonstationary variables with their (common) deflator
void addNonstationaryVariables(vector<int> nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false);
void addNonstationaryVariables(const vector<int> &nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false);
//! Is a given variable non-stationary?
bool isNonstationary(int symb_id) const;
void set_cutoff_to_zero();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment