From 4643fdaa4e909d99e5888e4a6574d066c7516482 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Tue, 8 Oct 2019 22:29:17 +0100 Subject: [PATCH] remove a few str copies when throwing exceptions --- src/api/api_solver.cpp | 4 +--- src/api/z3_replayer.cpp | 2 +- src/sat/sat_solver.cpp | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 29df0cb84..b267c4388 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -98,9 +98,7 @@ extern "C" { solver2smt2_pp::solver2smt2_pp(ast_manager& m, char const* file): m_pp_util(m), m_out(file) { if (!m_out) { - std::string msg; - msg = msg + "could not open " + file + " for output"; - throw default_exception(msg.c_str()); + throw default_exception("could not open " + std::string(file) + " for output"); } } diff --git a/src/api/z3_replayer.cpp b/src/api/z3_replayer.cpp index e898f2720..09cc8bba4 100644 --- a/src/api/z3_replayer.cpp +++ b/src/api/z3_replayer.cpp @@ -79,7 +79,7 @@ struct z3_replayer::imp { strm << "expecting " << kind2string(k) << " at position " << pos << " but got " << kind2string(m_args[pos].m_kind); TRACE("z3_replayer", tout << strm.str() << "\n";); - throw z3_replayer_exception(strm.str().c_str()); + throw z3_replayer_exception(strm.str()); } } diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index 9a1f9c01d..ea283895c 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -1464,7 +1464,7 @@ namespace sat { if (finished_id == -1) { switch (ex_kind) { case ERROR_EX: throw z3_error(error_code); - default: throw default_exception(ex_msg.c_str()); + default: throw default_exception(std::move(ex_msg)); } } return result;