Skip to content

Commit f23b053

Browse files
committed
remove a bunch of string copies
1 parent 97aa46a commit f23b053

File tree

2 files changed

+53
-37
lines changed

2 files changed

+53
-37
lines changed

‎src/solver/smt_logics.cpp‎

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,70 +29,85 @@ bool smt_logics::supported_logic(symbol const & s) {
2929
}
3030

3131
bool smt_logics::logic_has_reals_only(symbol const& s) {
32+
auto str = s.str();
3233
return
33-
s.str().find("LRA") != std::string::npos ||
34-
s.str().find("LRA") != std::string::npos ||
35-
s.str().find("NRA") != std::string::npos ||
36-
s.str().find("RDL") != std::string::npos;
34+
str.find("LRA") != std::string::npos ||
35+
str.find("LRA") != std::string::npos ||
36+
str.find("NRA") != std::string::npos ||
37+
str.find("RDL") != std::string::npos;
3738
}
3839

3940
bool smt_logics::logic_has_arith(symbol const & s) {
41+
auto str = s.str();
4042
return
41-
s.str().find("LRA") != std::string::npos ||
42-
s.str().find("LIRA") != std::string::npos ||
43-
s.str().find("LIA") != std::string::npos ||
44-
s.str().find("LRA") != std::string::npos ||
45-
s.str().find("NRA") != std::string::npos ||
46-
s.str().find("NIRA") != std::string::npos ||
47-
s.str().find("NIA") != std::string::npos ||
48-
s.str().find("IDL") != std::string::npos ||
49-
s.str().find("RDL") != std::string::npos ||
50-
s == "QF_BVRE" ||
51-
s == "QF_FP" ||
52-
s == "FP" ||
53-
s == "QF_FPBV" ||
54-
s == "QF_BVFP" ||
55-
s == "QF_S" ||
43+
str.find("LRA") != std::string::npos ||
44+
str.find("LIRA") != std::string::npos ||
45+
str.find("LIA") != std::string::npos ||
46+
str.find("LRA") != std::string::npos ||
47+
str.find("NRA") != std::string::npos ||
48+
str.find("NIRA") != std::string::npos ||
49+
str.find("NIA") != std::string::npos ||
50+
str.find("IDL") != std::string::npos ||
51+
str.find("RDL") != std::string::npos ||
52+
str == "QF_BVRE" ||
53+
str == "QF_FP" ||
54+
str == "FP" ||
55+
str == "QF_FPBV" ||
56+
str == "QF_BVFP" ||
57+
str == "QF_S" ||
5658
logic_is_all(s) ||
57-
s == "QF_FD" ||
58-
s == "HORN";
59+
str == "QF_FD" ||
60+
str == "HORN";
5961
}
6062

6163
bool smt_logics::logic_has_bv(symbol const & s) {
64+
auto str = s.str();
6265
return
63-
s.str().find("BV") != std::string::npos ||
64-
s == "FP" ||
66+
str.find("BV") != std::string::npos ||
67+
str == "FP" ||
6568
logic_is_all(s) ||
66-
s == "QF_FD" ||
67-
s == "SMTFD" ||
68-
s == "HORN";
69+
str == "QF_FD" ||
70+
str == "SMTFD" ||
71+
str == "HORN";
6972
}
7073

7174
bool smt_logics::logic_has_array(symbol const & s) {
75+
auto str = s.str();
7276
return
73-
s.str().starts_with("QF_A") ||
74-
s.str().starts_with("A") ||
77+
str.starts_with("QF_A") ||
78+
str.starts_with("A") ||
7579
logic_is_all(s) ||
76-
s == "SMTFD" ||
77-
s == "HORN";
80+
str == "SMTFD" ||
81+
str == "HORN";
7882
}
7983

8084
bool smt_logics::logic_has_seq(symbol const & s) {
8185
return s == "QF_BVRE" || logic_has_str(s);
8286
}
8387

8488
bool smt_logics::logic_has_str(symbol const & s) {
85-
return s == "QF_S" || s == "QF_SLIA" || s == "QF_SNIA" || logic_is_all(s);
89+
auto str = s.str();
90+
return str == "QF_S" ||
91+
str == "QF_SLIA" ||
92+
str == "QF_SNIA" ||
93+
logic_is_all(s);
8694
}
8795

8896
bool smt_logics::logic_has_fpa(symbol const & s) {
89-
return s == "FP" || s == "QF_FP" || s == "QF_FPBV" || s == "QF_BVFP" || s == "QF_FPLRA" || logic_is_all(s);
97+
auto str = s.str();
98+
return str == "FP" ||
99+
str == "QF_FP" ||
100+
str == "QF_FPBV" ||
101+
str == "QF_BVFP" ||
102+
str == "QF_FPLRA" ||
103+
logic_is_all(s);
90104
}
91105

92106
bool smt_logics::logic_has_uf(symbol const & s) {
107+
auto str = s.str();
93108
return
94-
s.str().find("UF") != std::string::npos ||
95-
s == "SMTFD";
109+
str.find("UF") != std::string::npos ||
110+
str == "SMTFD";
96111
}
97112

98113
bool smt_logics::logic_has_horn(symbol const& s) {
@@ -104,9 +119,10 @@ bool smt_logics::logic_has_pb(symbol const& s) {
104119
}
105120

106121
bool smt_logics::logic_has_datatype(symbol const& s) {
122+
auto str = s.str();
107123
return
108-
s.str().find("DT") != std::string::npos ||
109-
s == "QF_FD" ||
124+
str.find("DT") != std::string::npos ||
125+
str == "QF_FD" ||
110126
logic_is_all(s) ||
111127
logic_has_horn(s);
112128
}

‎src/util/gparams.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ struct gparams::imp {
416416
symbol sp(p.c_str());
417417
std::ostringstream buffer;
418418
ps.display(buffer, sp);
419-
return buffer.str();
419+
return std::move(buffer).str();
420420
}
421421

422422
std::string get_default(param_descrs const & d, std::string const & p, std::string const & m) {

0 commit comments

Comments
 (0)