From 699c32c52b3c7b09ba3d0e8d651a89a1b74222bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Sun, 20 Oct 2024 12:49:12 +0200 Subject: [PATCH] filterx-unset-empties: refactor eval() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- lib/filterx/func-unset-empties.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/filterx/func-unset-empties.c b/lib/filterx/func-unset-empties.c index 2a8e1321d..0ad388e3d 100644 --- a/lib/filterx/func-unset-empties.c +++ b/lib/filterx/func-unset-empties.c @@ -235,24 +235,17 @@ _eval(FilterXExpr *s) return NULL; } + gboolean success = FALSE; FilterXObject *obj_unwrapped = filterx_ref_unwrap_rw(obj); if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(dict))) - { - gboolean success = _process_dict(self, obj_unwrapped); - filterx_object_unref(obj); - return success ? filterx_boolean_new(TRUE) : NULL; - } - - if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(list))) - { - gboolean success = _process_list(self, obj_unwrapped); - filterx_object_unref(obj); - return success ? filterx_boolean_new(TRUE) : NULL; - } + success = _process_dict(self, obj_unwrapped); + else if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(list))) + success = _process_list(self, obj_unwrapped); + else + filterx_eval_push_error("Object must be dict or list. " FILTERX_FUNC_UNSET_EMPTIES_USAGE, s, obj); - filterx_eval_push_error("Object must be dict or list. " FILTERX_FUNC_UNSET_EMPTIES_USAGE, s, obj); filterx_object_unref(obj); - return NULL; + return success ? filterx_boolean_new(TRUE) : NULL; } static void