From 1e6a41186f5426cb691b194e3c6ec2f2513271c6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Mar 2018 09:56:29 +0530 Subject: [PATCH] Move check for NULL boss into call_boss() Negligible perf impact and makes it safe to use in different contexts --- kitty/screen.c | 2 +- kitty/state.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index dc5a7415c..9c55fb263 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1772,7 +1772,7 @@ screen_update_selection(Screen *self, index_type x, index_type y, bool ended) { break; } if (found) self->selection.end_x = end; - if (global_state.boss) call_boss(set_primary_selection, NULL); + call_boss(set_primary_selection, NULL); } static PyObject* diff --git a/kitty/state.h b/kitty/state.h index 99191a020..79e7352ac 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -137,7 +137,7 @@ typedef struct { extern GlobalState global_state; -#define call_boss(name, ...) { \ +#define call_boss(name, ...) if (global_state.boss) { \ PyObject *cret_ = PyObject_CallMethod(global_state.boss, #name, __VA_ARGS__); \ if (cret_ == NULL) { PyErr_Print(); } \ else Py_DECREF(cret_); \