From 3d94f1956c8dd3fde09fbc082d6dc397416403ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 13 Dec 2023 10:28:54 +0100 Subject: [PATCH] Remove some unneeded object copies Automatically detected by clang-tidy using performance-unnecessary-value-param check. --- src/Bytecode.hh | 2 +- src/ModelTree.cc | 4 ++-- src/SymbolTable.cc | 2 +- src/macro/Environment.cc | 4 ++-- src/macro/Environment.hh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bytecode.hh b/src/Bytecode.hh index 9527870e..6bb2f78d 100644 --- a/src/Bytecode.hh +++ b/src/Bytecode.hh @@ -844,7 +844,7 @@ public: void set_arg_func_name(string arg_arg_func_name) { - arg_func_name = arg_arg_func_name; + arg_func_name = move(arg_arg_func_name); }; string get_arg_func_name() diff --git a/src/ModelTree.cc b/src/ModelTree.cc index 65671fe9..6d8ae9a9 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -109,7 +109,7 @@ ModelTree::copyHelper(const ModelTree& m) blocks_derivatives.push_back(v); } - auto convert_vector_tt = [f](vector vtt) { + auto convert_vector_tt = [f](const vector& vtt) { vector vtt2; for (const auto& tt : vtt) { @@ -1927,7 +1927,7 @@ ModelTree::initializeMEXCompilationWorkers(int numworkers, const filesystem::pat cout << "Spawning " << numworkers << " threads for compiling MEX files." << endl; for (int i {0}; i < numworkers; i++) - mex_compilation_workers.emplace_back([](stop_token stoken) { + mex_compilation_workers.emplace_back([](const stop_token& stoken) { unique_lock lk {mex_compilation_mut}; filesystem::path output; string cmd; diff --git a/src/SymbolTable.cc b/src/SymbolTable.cc index 43e22c88..6b78152f 100644 --- a/src/SymbolTable.cc +++ b/src/SymbolTable.cc @@ -626,7 +626,7 @@ SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op, } aux_vars.emplace_back(symb_id, AuxVarType::unaryOp, move(orig_symb_id), move(orig_lag), 0, 0, - expr_arg, unary_op); + expr_arg, move(unary_op)); return symb_id; } diff --git a/src/macro/Environment.cc b/src/macro/Environment.cc index 8ee8bdd9..041011d2 100644 --- a/src/macro/Environment.cc +++ b/src/macro/Environment.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2019-2022 Dynare Team + * Copyright © 2019-2023 Dynare Team * * This file is part of Dynare. * @@ -25,7 +25,7 @@ using namespace macro; void -Environment::define(VariablePtr var, ExpressionPtr value) +Environment::define(const VariablePtr& var, const ExpressionPtr& value) { string name = var->getName(); if (functions.contains(name)) diff --git a/src/macro/Environment.hh b/src/macro/Environment.hh index a3f2cdfc..f55dd163 100644 --- a/src/macro/Environment.hh +++ b/src/macro/Environment.hh @@ -40,7 +40,7 @@ public: Environment(const Environment* parent_arg) : parent {parent_arg} { } - void define(VariablePtr var, ExpressionPtr value); + void define(const VariablePtr& var, const ExpressionPtr& value); void define(FunctionPtr func, ExpressionPtr value); /* The following two functions are not marked [[nodiscard]], because they are used without output to check whether they return an exception or not. */