mirror of
https://github.com/Z3Prover/z3
synced 2026-02-23 00:37:36 +00:00
Eliminate unnecessary copy operations in function parameters and range-based loops (#8589)
This commit is contained in:
parent
8fbf3f0169
commit
730a54a767
11 changed files with 34 additions and 34 deletions
|
|
@ -42,19 +42,19 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void add_option(std::string s) {
|
||||
void add_option(const std::string& s) {
|
||||
add_option_with_help_string(s, "");
|
||||
}
|
||||
|
||||
void add_option_with_help_string(std::string s, std::string help_string) {
|
||||
void add_option_with_help_string(const std::string& s, const std::string& help_string) {
|
||||
m_options[s]=help_string;
|
||||
}
|
||||
|
||||
void add_option_with_after_string(std::string s) {
|
||||
void add_option_with_after_string(const std::string& s) {
|
||||
add_option_with_after_string_with_help(s, "");
|
||||
}
|
||||
|
||||
void add_option_with_after_string_with_help(std::string s, std::string help_string) {
|
||||
void add_option_with_after_string_with_help(const std::string& s, const std::string& help_string) {
|
||||
m_options_with_after_string[s]=help_string;
|
||||
}
|
||||
|
||||
|
|
@ -82,19 +82,19 @@ public:
|
|||
return status_is_ok;
|
||||
}
|
||||
|
||||
bool contains(std::unordered_map<std::string, std::string> & m, std::string s) {
|
||||
bool contains(std::unordered_map<std::string, std::string> & m, const std::string& s) {
|
||||
return m.find(s) != m.end();
|
||||
}
|
||||
|
||||
bool contains(std::set<std::string> & m, std::string s) {
|
||||
bool contains(std::set<std::string> & m, const std::string& s) {
|
||||
return m.find(s) != m.end();
|
||||
}
|
||||
|
||||
bool option_is_used(std::string option) {
|
||||
bool option_is_used(const std::string& option) {
|
||||
return contains(m_used_options, option) || contains(m_used_options_with_after_string, option);
|
||||
}
|
||||
|
||||
std::string get_option_value(std::string option) {
|
||||
std::string get_option_value(const std::string& option) {
|
||||
auto t = m_used_options_with_after_string.find(option);
|
||||
if (t != m_used_options_with_after_string.end()){
|
||||
return t->second;
|
||||
|
|
@ -102,11 +102,11 @@ public:
|
|||
return std::string();
|
||||
}
|
||||
|
||||
bool starts_with(std::string s, char const * prefix) {
|
||||
bool starts_with(const std::string& s, char const * prefix) {
|
||||
return starts_with(s, std::string(prefix));
|
||||
}
|
||||
|
||||
bool starts_with(std::string s, std::string prefix) {
|
||||
bool starts_with(const std::string& s, const std::string& prefix) {
|
||||
return s.substr(0, prefix.size()) == prefix;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -684,11 +684,11 @@ std::string create_output_file_name(bool minimize, std::string file_name,
|
|||
}
|
||||
|
||||
std::string create_output_file_name_for_glpsol(bool minimize,
|
||||
std::string file_name) {
|
||||
const std::string& file_name) {
|
||||
return file_name + (minimize ? "_min" : "_max") + "_glpk_out";
|
||||
}
|
||||
|
||||
int run_glpk(std::string file_name, std::string glpk_out_file_name,
|
||||
int run_glpk(const std::string& file_name, const std::string& glpk_out_file_name,
|
||||
bool minimize, unsigned time_limit) {
|
||||
std::string minmax(minimize ? "--min" : "--max");
|
||||
std::string tmlim = time_limit > 0 ? std::string(" --tmlim ") +
|
||||
|
|
@ -700,7 +700,7 @@ int run_glpk(std::string file_name, std::string glpk_out_file_name,
|
|||
return system(command_line.c_str());
|
||||
}
|
||||
|
||||
std::string get_status(std::string file_name) {
|
||||
std::string get_status(const std::string& file_name) {
|
||||
std::ifstream f(file_name);
|
||||
if (!f.is_open()) {
|
||||
std::cout << "cannot open " << file_name << std::endl;
|
||||
|
|
@ -728,7 +728,7 @@ struct sort_pred {
|
|||
}
|
||||
};
|
||||
|
||||
vector<std::string> get_file_names_from_file_list(std::string filelist) {
|
||||
vector<std::string> get_file_names_from_file_list(const std::string& filelist) {
|
||||
std::ifstream file(filelist);
|
||||
if (!file.is_open()) {
|
||||
std::cout << "cannot open " << filelist << std::endl;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace lp {
|
|||
lconstraint_kind m_kind;
|
||||
std::vector<std::pair<mpq, std::string>> m_coeffs;
|
||||
mpq m_right_side;
|
||||
void add_pair(mpq c, std::string name) {
|
||||
void add_pair(mpq c, const std::string& name) {
|
||||
m_coeffs.push_back(make_pair(c, name));
|
||||
}
|
||||
formula_constraint() : m_right_side(numeric_traits<mpq>::zero()) {}
|
||||
|
|
@ -81,7 +81,7 @@ namespace lp {
|
|||
std::string m_file_name;
|
||||
std::ifstream m_file_stream;
|
||||
std::string m_line;
|
||||
smt_reader(std::string file_name):
|
||||
smt_reader(const std::string& file_name):
|
||||
m_is_OK(true),
|
||||
m_line_number(0),
|
||||
m_file_name(file_name),
|
||||
|
|
@ -372,7 +372,7 @@ namespace lp {
|
|||
}
|
||||
*/
|
||||
|
||||
unsigned register_name(std::string s) {
|
||||
unsigned register_name(const std::string& s) {
|
||||
auto it = m_name_to_var_index.find(s);
|
||||
if (it!= m_name_to_var_index.end())
|
||||
return it->second;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class test_file_reader {
|
|||
std::ifstream m_file_stream;
|
||||
public:
|
||||
// constructor
|
||||
test_file_reader(std::string file_name) : m_file_stream(file_name) {
|
||||
test_file_reader(const std::string& file_name) : m_file_stream(file_name) {
|
||||
if (!m_file_stream.is_open()) {
|
||||
std::cout << "cannot open file " << "\'" << file_name << "\'" << std::endl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue