mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
remove a bunch of string copies in the API
thanks to C++20
This commit is contained in:
parent
a4ece21461
commit
1720addc4e
|
@ -395,8 +395,7 @@ extern "C" {
|
||||||
Z3_string s) {
|
Z3_string s) {
|
||||||
Z3_TRY;
|
Z3_TRY;
|
||||||
LOG_Z3_fixedpoint_from_string(c, d, s);
|
LOG_Z3_fixedpoint_from_string(c, d, s);
|
||||||
std::string str(s);
|
std::istringstream is(s);
|
||||||
std::istringstream is(str);
|
|
||||||
RETURN_Z3(Z3_fixedpoint_from_stream(c, d, is));
|
RETURN_Z3(Z3_fixedpoint_from_stream(c, d, is));
|
||||||
Z3_CATCH_RETURN(nullptr);
|
Z3_CATCH_RETURN(nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,8 +383,7 @@ extern "C" {
|
||||||
Z3_string s) {
|
Z3_string s) {
|
||||||
Z3_TRY;
|
Z3_TRY;
|
||||||
//LOG_Z3_optimize_from_string(c, d, s);
|
//LOG_Z3_optimize_from_string(c, d, s);
|
||||||
std::string str(s);
|
std::istringstream is(s);
|
||||||
std::istringstream is(str);
|
|
||||||
Z3_optimize_from_stream(c, d, is, nullptr);
|
Z3_optimize_from_stream(c, d, is, nullptr);
|
||||||
Z3_CATCH;
|
Z3_CATCH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ extern "C" {
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
std::ostringstream buffer;
|
std::ostringstream buffer;
|
||||||
to_params(p)->m_params.display(buffer);
|
to_params(p)->m_params.display(buffer);
|
||||||
return mk_c(c)->mk_external_string(buffer.str());
|
return mk_c(c)->mk_external_string(std::move(buffer).str());
|
||||||
Z3_CATCH_RETURN("");
|
Z3_CATCH_RETURN("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ extern "C" {
|
||||||
buffer << to_param_descrs_ptr(p)->get_param_name(i);
|
buffer << to_param_descrs_ptr(p)->get_param_name(i);
|
||||||
}
|
}
|
||||||
buffer << ")";
|
buffer << ")";
|
||||||
return mk_c(c)->mk_external_string(buffer.str());
|
return mk_c(c)->mk_external_string(std::move(buffer).str());
|
||||||
Z3_CATCH_RETURN("");
|
Z3_CATCH_RETURN("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,7 @@ extern "C" {
|
||||||
Z3_ast_vector Z3_API Z3_parser_context_from_string(Z3_context c, Z3_parser_context pc, Z3_string str) {
|
Z3_ast_vector Z3_API Z3_parser_context_from_string(Z3_context c, Z3_parser_context pc, Z3_string str) {
|
||||||
Z3_TRY;
|
Z3_TRY;
|
||||||
LOG_Z3_parser_context_from_string(c, pc, str);
|
LOG_Z3_parser_context_from_string(c, pc, str);
|
||||||
std::string s(str);
|
std::istringstream is(str);
|
||||||
std::istringstream is(s);
|
|
||||||
auto& ctx = to_parser_context(pc)->ctx;
|
auto& ctx = to_parser_context(pc)->ctx;
|
||||||
Z3_ast_vector r = Z3_parser_context_parse_stream(c, ctx, false, is);
|
Z3_ast_vector r = Z3_parser_context_parse_stream(c, ctx, false, is);
|
||||||
RETURN_Z3(r);
|
RETURN_Z3(r);
|
||||||
|
@ -202,8 +201,7 @@ extern "C" {
|
||||||
Z3_func_decl const decls[]) {
|
Z3_func_decl const decls[]) {
|
||||||
Z3_TRY;
|
Z3_TRY;
|
||||||
LOG_Z3_parse_smtlib2_string(c, str, num_sorts, sort_names, sorts, num_decls, decl_names, decls);
|
LOG_Z3_parse_smtlib2_string(c, str, num_sorts, sort_names, sorts, num_decls, decl_names, decls);
|
||||||
std::string s(str);
|
std::istringstream is(str);
|
||||||
std::istringstream is(s);
|
|
||||||
Z3_ast_vector r = parse_smtlib2_stream(false, c, is, num_sorts, sort_names, sorts, num_decls, decl_names, decls);
|
Z3_ast_vector r = parse_smtlib2_stream(false, c, is, num_sorts, sort_names, sorts, num_decls, decl_names, decls);
|
||||||
RETURN_Z3(r);
|
RETURN_Z3(r);
|
||||||
Z3_CATCH_RETURN(nullptr);
|
Z3_CATCH_RETURN(nullptr);
|
||||||
|
@ -243,8 +241,7 @@ extern "C" {
|
||||||
ctx->set_solver_factory(mk_smt_strategic_solver_factory());
|
ctx->set_solver_factory(mk_smt_strategic_solver_factory());
|
||||||
}
|
}
|
||||||
scoped_ptr<cmd_context>& ctx = mk_c(c)->cmd();
|
scoped_ptr<cmd_context>& ctx = mk_c(c)->cmd();
|
||||||
std::string s(str);
|
std::istringstream is(str);
|
||||||
std::istringstream is(s);
|
|
||||||
ctx->set_regular_stream(ous);
|
ctx->set_regular_stream(ous);
|
||||||
ctx->set_diagnostic_stream(ous);
|
ctx->set_diagnostic_stream(ous);
|
||||||
cmd_context::scoped_redirect _redirect(*ctx);
|
cmd_context::scoped_redirect _redirect(*ctx);
|
||||||
|
|
|
@ -318,8 +318,7 @@ extern "C" {
|
||||||
void Z3_API Z3_solver_from_string(Z3_context c, Z3_solver s, Z3_string c_str) {
|
void Z3_API Z3_solver_from_string(Z3_context c, Z3_solver s, Z3_string c_str) {
|
||||||
Z3_TRY;
|
Z3_TRY;
|
||||||
LOG_Z3_solver_from_string(c, s, c_str);
|
LOG_Z3_solver_from_string(c, s, c_str);
|
||||||
std::string str(c_str);
|
std::istringstream is(c_str);
|
||||||
std::istringstream is(str);
|
|
||||||
if (is_dimacs_string(c_str)) {
|
if (is_dimacs_string(c_str)) {
|
||||||
solver_from_dimacs_stream(c, s, is);
|
solver_from_dimacs_stream(c, s, is);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue