fix(*): remove unnecessary null pointer checks

closes #514
This commit is contained in:
Leonardo de Moura 2015-03-28 12:16:39 -07:00
parent 0cda3f7cbf
commit 88495f9d59
6 changed files with 16 additions and 32 deletions

View file

@ -21,8 +21,7 @@ bool get_formatter_hide_full_terms(options const & opts) { return opts.get_bool(
static std::function<void(std::ostream &, expr const & e)> * g_print = nullptr;
void set_print_fn(std::function<void(std::ostream &, expr const &)> const & fn) {
if (g_print)
delete g_print;
delete g_print;
g_print = new std::function<void(std::ostream &, expr const &)>(fn);
}
@ -45,7 +44,6 @@ void initialize_formatter() {
void finalize_formatter() {
delete g_formatter_hide_full;
if (g_print)
delete g_print;
delete g_print;
}
}

View file

@ -18,10 +18,8 @@ using namespace lean;
#if defined(LEAN_MULTI_THREAD) && !defined(__APPLE__)
LEAN_THREAD_PTR(std::vector<int>, g_v);
void finalize_vector() {
if (g_v) {
delete g_v;
g_v = nullptr;
}
delete g_v;
g_v = nullptr;
}
void foo() {
if (!g_v) {

View file

@ -26,8 +26,7 @@ void initialize_debug() {
}
void finalize_debug() {
if (g_enabled_debug_tags)
delete g_enabled_debug_tags;
delete g_enabled_debug_tags;
}
bool has_violations() {

View file

@ -172,10 +172,8 @@ public:
#define MK_THREAD_LOCAL_GET(T, GETTER_NAME, DEF_VALUE) \
LEAN_THREAD_PTR(T, GETTER_NAME ## _tlocal); \
static void finalize_ ## GETTER_NAME() { \
if (GETTER_NAME ## _tlocal) { \
delete GETTER_NAME ## _tlocal; \
GETTER_NAME ## _tlocal = nullptr; \
} \
delete GETTER_NAME ## _tlocal; \
GETTER_NAME ## _tlocal = nullptr; \
} \
static T & GETTER_NAME() { \
if (!GETTER_NAME ## _tlocal) { \
@ -188,10 +186,8 @@ static T & GETTER_NAME() { \
#define MK_THREAD_LOCAL_GET_DEF(T, GETTER_NAME) \
LEAN_THREAD_PTR(T, GETTER_NAME ## _tlocal); \
static void finalize_ ## GETTER_NAME() { \
if (GETTER_NAME ## _tlocal) { \
delete GETTER_NAME ## _tlocal; \
GETTER_NAME ## _tlocal = nullptr; \
} \
delete GETTER_NAME ## _tlocal; \
GETTER_NAME ## _tlocal = nullptr; \
} \
static T & GETTER_NAME() { \
if (!GETTER_NAME ## _tlocal) { \

View file

@ -124,14 +124,10 @@ LEAN_THREAD_PTR(bool, g_registered);
LEAN_THREAD_PTR(script_state_ref, g_thread_state_ref);
static void finalize_thread_state_ref() {
if (g_thread_state_ref) {
delete g_thread_state_ref;
g_thread_state_ref = nullptr;
}
if (g_registered) {
delete g_registered;
g_registered = nullptr;
}
delete g_thread_state_ref;
g_thread_state_ref = nullptr;
delete g_registered;
g_registered = nullptr;
}
script_state get_thread_script_state() {
@ -146,9 +142,7 @@ script_state get_thread_script_state() {
}
void release_thread_script_state() {
if (g_thread_state_ref) {
delete g_thread_state_ref;
g_thread_state_ref = nullptr;
}
delete g_thread_state_ref;
g_thread_state_ref = nullptr;
}
}

View file

@ -28,8 +28,7 @@ void initialize_trace() {
}
void finalize_trace() {
if (g_enabled_trace_tags)
delete g_enabled_trace_tags;
delete g_enabled_trace_tags;
}
void enable_trace(char const * tag) {