From 1793078ba2a533e92602eb0dc93a7003a0ae1720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Mon, 18 Mar 2019 18:49:51 +0100 Subject: [PATCH] Minor stylistic improvements --- src/DataTree.hh | 2 +- src/ExprNode.hh | 4 ++-- src/ExternalFunctionsTable.hh | 6 +++--- src/Statement.cc | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/DataTree.hh b/src/DataTree.hh index 1b3453f5..f64e6228 100644 --- a/src/DataTree.hh +++ b/src/DataTree.hh @@ -106,7 +106,7 @@ protected: static string packageDir(const string &package); private: - const static int constants_precision{16}; + constexpr static int constants_precision{16}; //! The list of nodes vector<unique_ptr<ExprNode>> node_list; diff --git a/src/ExprNode.hh b/src/ExprNode.hh index 083f2f5a..af4ed5e6 100644 --- a/src/ExprNode.hh +++ b/src/ExprNode.hh @@ -181,8 +181,8 @@ class ExprNode //! Used for caching of first order derivatives (when non-null) map<int, expr_t> derivatives; - const static int min_cost_matlab{40*90}; - const static int min_cost_c{40*4}; + constexpr static int min_cost_matlab{40*90}; + constexpr static int min_cost_c{40*4}; inline static int min_cost(bool is_matlab) { return(is_matlab ? min_cost_matlab : min_cost_c); }; //! Cost of computing current node diff --git a/src/ExternalFunctionsTable.hh b/src/ExternalFunctionsTable.hh index 56c1ee74..0b5b22c6 100644 --- a/src/ExternalFunctionsTable.hh +++ b/src/ExternalFunctionsTable.hh @@ -53,11 +53,11 @@ public: }; using external_function_table_type = map<int, external_function_options>; //! Symbol ID used when no external function exists that calculates the derivative - const static int IDNotSet = -1; + constexpr static int IDNotSet = -1; //! Symbol ID used when the derivative is obtained from the top-level function - const static int IDSetButNoNameProvided = -2; + constexpr static int IDSetButNoNameProvided = -2; //! Default number of arguments when nargs is not specified - const static int defaultNargs = 1; + constexpr static int defaultNargs = 1; private: //! Map containing options provided to external_functions() external_function_table_type externalFunctionTable; diff --git a/src/Statement.cc b/src/Statement.cc index 80d3548d..e1f992a8 100644 --- a/src/Statement.cc +++ b/src/Statement.cc @@ -143,8 +143,8 @@ void OptionsList::writeOutput(ostream &output, const string &option_group) const { // Initialize option_group as an empty struct iff the field does not exist! - unsigned idx = option_group.find_last_of("."); - if (idx < UINT_MAX) + size_t idx = option_group.find_last_of("."); + if (idx != string::npos) { output << "if ~isfield(" << option_group.substr(0, idx) << ",'" << option_group.substr(idx+1) << "')" << endl; output << " " << option_group << " = struct();" << endl; -- GitLab