From 13dc0a11447107e0e8d5299fa3a8bfaf89295a74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 22 Jun 2022 12:47:11 +0200
Subject: [PATCH] Use operator""s to replace some calls to std::string
 constructor

By the way, remove other unnecessary calls to that constructor.
---
 src/DataTree.cc      | 2 +-
 src/DynamicModel.cc  | 2 +-
 src/DynareFlex.ll    | 6 +++---
 src/ModelTree.cc     | 2 +-
 src/ParsingDriver.cc | 2 +-
 src/StaticModel.cc   | 2 +-
 src/SymbolTable.cc   | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/DataTree.cc b/src/DataTree.cc
index 22a6fb8d..7044d98e 100644
--- a/src/DataTree.cc
+++ b/src/DataTree.cc
@@ -404,7 +404,7 @@ DataTree::AddDiff(expr_t iArg1)
 expr_t
 DataTree::AddAdl(expr_t iArg1, const string &name, const vector<int> &lags)
 {
-  return AddUnaryOp(UnaryOpcode::adl, iArg1, 0, 0, 0, string(name), lags);
+  return AddUnaryOp(UnaryOpcode::adl, iArg1, 0, 0, 0, name, lags);
 }
 
 expr_t
diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index 281a885d..72257001 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -505,7 +505,7 @@ DynamicModel::writeDynamicPerBlockMFiles(const string &basename) const
         output << "function [residual, y, T, g1, varargout] = dynamic_" << blk+1 << "(y, x, params, steady_state, T, it_, stochastic_mode)" << endl;
 
       output << "  % ////////////////////////////////////////////////////////////////////////" << endl
-             << "  % //" << string("                     Block ").substr(static_cast<int>(log10(blk + 1))) << blk+1
+             << "  % //" << "                     Block "s.substr(static_cast<int>(log10(blk + 1))) << blk+1
              << "                                        //" << endl
              << "  % //                     Simulation type "
              << BlockSim(simulation_type) << "  //" << endl
diff --git a/src/DynareFlex.ll b/src/DynareFlex.ll
index 23de13ca..3b6688c7 100644
--- a/src/DynareFlex.ll
+++ b/src/DynareFlex.ll
@@ -83,7 +83,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
  /* Rules for matching $line directives */
 <*>^@#line\ \"  { line_caller = YYSTATE; BEGIN(LINE1); }
 <LINE1>[^\"]*   {
-                  filename = string(yytext);
+                  filename = yytext;
                   BEGIN(LINE2);
                 }
 <LINE2>\"       BEGIN(LINE3);
@@ -1127,7 +1127,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
     and move to the NATIVE context
  */
 <INITIAL>\[([[:space:]]*[a-z_][a-z0-9_]*[[:space:]]*,{1}[[:space:]]*)*([[:space:]]*[a-z_][a-z0-9_]*[[:space:]]*){1}\] {
-  string yytextcpy = string(yytext);
+  string yytextcpy{yytext};
   yytextcpy.erase(remove(yytextcpy.begin(), yytextcpy.end(), '['), yytextcpy.end());
   yytextcpy.erase(remove(yytextcpy.begin(), yytextcpy.end(), ']'), yytextcpy.end());
   yytextcpy.erase(remove(yytextcpy.begin(), yytextcpy.end(), ' '), yytextcpy.end());
@@ -1166,7 +1166,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
   \"[^\"\n]*\"                |
   \.{1,2}                     |
   \*                          |
-  \/                          { yymore(); eofbuff = string(yytext); }
+  \/                          { yymore(); eofbuff = yytext; }
   \.{3,}[[:space:]]*\n        { driver.add_native_remove_charset(yytext, "\n"); }
   \n                          {
                                 if (strlen(yytext) > 1)
diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index 8b2ff1cd..ee58009b 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -1890,7 +1890,7 @@ ModelTree::compileMEX(const string &basename, const string &funcname, const stri
           flags << " -static-libgcc -shared";
           // Put the MinGW environment shipped with Dynare in the path
           auto mingwpath = dynareroot / "mingw64" / "bin";
-          string newpath = "PATH=" + mingwpath.string() + ';' + string{getenv("PATH")};
+          string newpath = "PATH=" + mingwpath.string() + ';' + getenv("PATH");
           /* We can’t use setenv() since it is not available on MinGW. Note
             that putenv() seems to make a copy of the string on MinGW, contrary
             to what is done on GNU/Linux and macOS. */
diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc
index 08f93f01..5194429a 100644
--- a/src/ParsingDriver.cc
+++ b/src/ParsingDriver.cc
@@ -3146,7 +3146,7 @@ ParsingDriver::add_model_var_or_external_function(const string &function_name, b
       if (!in_model_block && !parsing_epilogue && !parsing_pac_model)
         {
           if (stack_external_function_args.top().size() > 0)
-            error(string("Symbol ") + function_name + string(" cannot take arguments."));
+            error("Symbol " + function_name + " cannot take arguments.");
           else
             return add_expression_variable(function_name);
         }
diff --git a/src/StaticModel.cc b/src/StaticModel.cc
index f016a2c9..6ae1b984 100644
--- a/src/StaticModel.cc
+++ b/src/StaticModel.cc
@@ -260,7 +260,7 @@ StaticModel::writeStaticPerBlockMFiles(const string &basename) const
         output << "function [residual, y, T, g1] = static_" << blk+1 << "(y, x, params, T)" << endl;
 
       output << "  % ////////////////////////////////////////////////////////////////////////" << endl
-             << "  % //" << string("                     Block ").substr(static_cast<int>(log10(blk + 1))) << blk+1
+             << "  % //" << "                     Block "s.substr(static_cast<int>(log10(blk + 1))) << blk+1
              << "                                        //" << endl
              << "  % //                     Simulation type "
              << BlockSim(simulation_type) << "  //" << endl
diff --git a/src/SymbolTable.cc b/src/SymbolTable.cc
index fa6dc234..949a7fee 100644
--- a/src/SymbolTable.cc
+++ b/src/SymbolTable.cc
@@ -486,7 +486,7 @@ SymbolTable::addExoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag, expr_t e
 int
 SymbolTable::addExpectationAuxiliaryVar(int information_set, int index, expr_t expr_arg) noexcept(false)
 {
-  string varname{string{"AUX_EXPECT_"} + (information_set < 0 ? "LAG" : "LEAD") + "_"
+  string varname{"AUX_EXPECT_"s + (information_set < 0 ? "LAG" : "LEAD") + "_"
     + to_string(abs(information_set)) + "_" + to_string(index)};
   int symb_id;
   try
-- 
GitLab