@@ -58,13 +58,13 @@ static bool is_char_number(const char ch);
5858static bool is_operator (const char ch);
5959
6060// returns true if the specified name is a known function operator
61- static bool is_function (std::string name);
61+ static bool is_function (const std::string& name);
6262
6363// returns true if the specified name is a known compound operator
6464t_compound_operator is_compound_op (const char * ch);
6565
6666// returns true if the specified name is a known variable
67- static bool is_variable (std::string var);
67+ static bool is_variable (const std::string& var);
6868
6969// returns the length of any identifier (e.g. name, function) starting at the beginning of str
7070static int identifier_length (const char * str);
@@ -76,14 +76,14 @@ static bool goto_next_char(int* str_ind, const string& pw_formula, char ch);
7676bool same_string (std::string str1, std::string str2);
7777
7878// checks if the block indicated by the user was one of the moved blocks in the last perturbation
79- int in_blocks_affected (std::string expression_left);
79+ int in_blocks_affected (const std::string& expression_left);
8080
8181// the function of += operator
8282bool additional_assignment_op (int arg1, int arg2);
8383
8484/* *** Function Implementations ****/
8585/* returns integer result according to specified non-piece-wise formula and data */
86- int FormulaParser::parse_formula (std::string formula, const t_formula_data& mydata, bool is_breakpoint) {
86+ int FormulaParser::parse_formula (const std::string& formula, const t_formula_data& mydata, bool is_breakpoint) {
8787 int result = -1 ;
8888
8989 /* output in reverse-polish notation */
@@ -150,7 +150,7 @@ int FormulaParser::parse_piecewise_formula(const char* formula, const t_formula_
150150 }
151151 tmp_ind_count = str_ind - tmp_ind_start; /* range start is between { and : */
152152 substr = pw_formula.substr (tmp_ind_start, tmp_ind_count);
153- range_start = parse_formula (substr. c_str () , mydata);
153+ range_start = parse_formula (substr, mydata);
154154
155155 /* get the end of the range */
156156 tmp_ind_start = str_ind + 1 ;
@@ -160,7 +160,7 @@ int FormulaParser::parse_piecewise_formula(const char* formula, const t_formula_
160160 }
161161 tmp_ind_count = str_ind - tmp_ind_start; /* range end is between : and } */
162162 substr = pw_formula.substr (tmp_ind_start, tmp_ind_count);
163- range_end = parse_formula (substr. c_str () , mydata);
163+ range_end = parse_formula (substr, mydata);
164164
165165 if (range_start > range_end) {
166166 throw vtr::VtrError (vtr::string_fmt (" parse_piecewise_formula: range_start, %d, is bigger than range end, %d\n " , range_start, range_end), __FILE__, __LINE__);
@@ -287,8 +287,6 @@ static void formula_to_rpn(const char* formula, const t_formula_data& mydata, ve
287287 rpn_output.push_back (fobj_dummy);
288288 op_stack.pop ();
289289 }
290-
291- return ;
292290}
293291
294292/* Fills the formula object fobj according to specified character and mydata,
@@ -352,7 +350,7 @@ static void get_formula_object(const char* ch, int& ichar, const t_formula_data&
352350 }
353351 ichar--;
354352 fobj->type = E_FML_NUMBER;
355- fobj->data .num = vtr::atoi (ss.str (). c_str () );
353+ fobj->data .num = vtr::atoi (ss.str ());
356354 } else if (is_compound_op (ch) != E_COM_OP_UNDEFINED) {
357355 fobj->type = E_FML_OPERATOR;
358356 t_compound_operator comp_op_code = is_compound_op (ch);
@@ -415,8 +413,6 @@ static void get_formula_object(const char* ch, int& ichar, const t_formula_data&
415413 break ;
416414 }
417415 }
418-
419- return ;
420416}
421417
422418/* returns integer specifying precedence of passed-in operator. higher integer
@@ -562,7 +558,6 @@ static void handle_bracket(const Formula_Object& fobj, vector<Formula_Object>& r
562558 }
563559 } while (keep_going);
564560 }
565- return ;
566561}
567562
568563/* used by the shunting-yard formula parser to deal with commas, ie ','. These occur in function calls*/
@@ -770,7 +765,7 @@ static bool is_operator(const char ch) {
770765}
771766
772767// returns true if string signifies a function e.g max, min
773- static bool is_function (std::string name) {
768+ static bool is_function (const std::string& name) {
774769 if (name == " min"
775770 || name == " max"
776771 || name == " gcd"
@@ -801,7 +796,7 @@ t_compound_operator is_compound_op(const char* ch) {
801796}
802797
803798// checks if the entered string is a known variable name
804- static bool is_variable (std::string var_name) {
799+ static bool is_variable (const std::string& var_name) {
805800 if (same_string (var_name, " from_block" ) || same_string (var_name, " temp_count" ) || same_string (var_name, " move_num" ) || same_string (var_name, " route_net_id" ) || same_string (var_name, " in_blocks_affected" ) || same_string (var_name, " router_iter" )) {
806801 return true ;
807802 }
@@ -849,11 +844,11 @@ bool same_string(std::string str1, std::string str2) {
849844 str1.erase (remove (str1.begin (), str1.end (), ' ' ), str1.end ());
850845 str2.erase (remove (str2.begin (), str2.end (), ' ' ), str2.end ());
851846
852- // converting both strings to lower case to eliminate case sensivity
847+ // converting both strings to lower case to eliminate case sensitivity
853848 std::transform (str1.begin (), str1.end (), str1.begin (), ::tolower);
854849 std::transform (str2.begin (), str2.end (), str2.begin (), ::tolower);
855850
856- return (str1. compare (str2) == 0 );
851+ return (str1 == str2 );
857852}
858853
859854// the += operator
@@ -870,7 +865,7 @@ bool additional_assignment_op(int arg1, int arg2) {
870865// recognizes the block_id to look for (entered by the user)
871866// then looks for that block_id in all the blocks moved in the last perturbation.
872867// returns the block id if found, else just -1
873- int in_blocks_affected (std::string expression_left) {
868+ int in_blocks_affected (const std::string& expression_left) {
874869 int wanted_block = -1 ;
875870 int found_block;
876871 std::stringstream ss;
0 commit comments