Skip to content

Commit

Permalink
remove a few string copies
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Dec 19, 2023
1 parent e5f52e2 commit fcc7b25
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/api/api_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,7 @@ extern "C" {
RESET_ERROR_CODE();
symbol _s = to_symbol(s);
if (_s.is_numerical()) {
std::ostringstream buffer;
buffer << _s.get_num();
return mk_c(c)->mk_external_string(buffer.str());
return mk_c(c)->mk_external_string(std::to_string(_s.get_num()));
}
else {
return mk_c(c)->mk_external_string(_s.str());
Expand Down Expand Up @@ -823,7 +821,7 @@ extern "C" {
param_descrs descrs;
th_rewriter::get_param_descrs(descrs);
descrs.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("");
}

Expand Down Expand Up @@ -1031,7 +1029,7 @@ extern "C" {
default:
UNREACHABLE();
}
return mk_c(c)->mk_external_string(buffer.str());
return mk_c(c)->mk_external_string(std::move(buffer).str());
Z3_CATCH_RETURN(nullptr);
}

Expand Down Expand Up @@ -1066,7 +1064,7 @@ extern "C" {
pp.add_assumption(to_expr(assumptions[i]));
}
pp.display_smt2(buffer, to_expr(formula));
return mk_c(c)->mk_external_string(buffer.str());
return mk_c(c)->mk_external_string(std::move(buffer).str());
Z3_CATCH_RETURN("");
}

Expand Down

0 comments on commit fcc7b25

Please sign in to comment.