3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

remove some allocs from exceptions

This commit is contained in:
Nuno Lopes 2018-07-02 17:08:02 +01:00
parent 8791f61aa7
commit cef17c22a1
19 changed files with 36 additions and 40 deletions

View file

@ -55,8 +55,8 @@ class cmd_exception : public default_exception {
}
public:
cmd_exception(char const * msg):default_exception(msg), m_line(-1), m_pos(-1) {}
cmd_exception(std::string const & msg):default_exception(msg), m_line(-1), m_pos(-1) {}
cmd_exception(std::string const & msg, int line, int pos):default_exception(msg), m_line(line), m_pos(pos) {}
cmd_exception(std::string && msg):default_exception(std::move(msg)), m_line(-1), m_pos(-1) {}
cmd_exception(std::string && msg, int line, int pos):default_exception(std::move(msg)), m_line(line), m_pos(pos) {}
cmd_exception(char const * msg, symbol const & s):
default_exception(compose(msg,s)),m_line(-1),m_pos(-1) {}
cmd_exception(char const * msg, symbol const & s, int line, int pos):

View file

@ -356,7 +356,7 @@ public:
}
}
if (error)
throw exception(error_msg);
throw exception(std::move(error_msg));
}
std::string get_value(params_ref const & ps, symbol const & p) {
@ -417,7 +417,7 @@ public:
}
}
if (error)
throw exception(error_msg);
throw exception(std::move(error_msg));
return r;
}
@ -509,7 +509,7 @@ public:
}
}
if (error)
throw exception(error_msg);
throw exception(std::move(error_msg));
}
void display_parameter(std::ostream & out, char const * name) {
@ -550,7 +550,7 @@ public:
}
}
if (error)
throw exception(error_msg);
throw exception(std::move(error_msg));
}
};

View file

@ -36,8 +36,8 @@ bool contains(const std::unordered_map<A, B> & map, const A& key) {
}
namespace lp {
inline void throw_exception(const std::string & str) {
throw default_exception(str);
inline void throw_exception(std::string && str) {
throw default_exception(std::move(str));
}
typedef z3_exception exception;

View file

@ -27,9 +27,10 @@ Revision History:
#include "util/event_handler.h"
#include "util/scoped_timer.h"
scoped_timer * g_timeout = nullptr;
void (* g_on_timeout)() = nullptr;
static scoped_timer * g_timeout = nullptr;
static void (* g_on_timeout)() = nullptr;
namespace {
class g_timeout_eh : public event_handler {
public:
void operator()(event_handler_caller_t caller_id) override {
@ -46,6 +47,7 @@ public:
}
}
};
}
void set_timeout(long ms) {
if (g_timeout)

View file

@ -67,9 +67,6 @@ default_exception::default_exception(fmt, char const* msg, ...) {
m_msg = out.str();
}
default_exception::default_exception(std::string const & msg): m_msg(msg) {
}
char const * default_exception::msg() const {
return m_msg.c_str();
}

View file

@ -41,7 +41,7 @@ class default_exception : public z3_exception {
std::string m_msg;
public:
struct fmt {};
default_exception(std::string const& msg);
default_exception(std::string && msg) : m_msg(std::move(msg)) {}
default_exception(fmt, char const* msg, ...);
~default_exception() override {}
char const * msg() const override;