Skip to content

Commit bfc0c4c

Browse files
committed
filterx-unset-empties: refactor eval()
Signed-off-by: László Várady <[email protected]>
1 parent 33c471c commit bfc0c4c

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

lib/filterx/func-unset-empties.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,24 +235,17 @@ _eval(FilterXExpr *s)
235235
return NULL;
236236
}
237237

238+
gboolean success = FALSE;
238239
FilterXObject *obj_unwrapped = filterx_ref_unwrap_rw(obj);
239240
if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(dict)))
240-
{
241-
gboolean success = _process_dict(self, obj_unwrapped);
242-
filterx_object_unref(obj);
243-
return success ? filterx_boolean_new(TRUE) : NULL;
244-
}
245-
246-
if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(list)))
247-
{
248-
gboolean success = _process_list(self, obj_unwrapped);
249-
filterx_object_unref(obj);
250-
return success ? filterx_boolean_new(TRUE) : NULL;
251-
}
241+
success = _process_dict(self, obj_unwrapped);
242+
else if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(list)))
243+
success = _process_list(self, obj_unwrapped);
244+
else
245+
filterx_eval_push_error("Object must be dict or list. " FILTERX_FUNC_UNSET_EMPTIES_USAGE, s, obj);
252246

253-
filterx_eval_push_error("Object must be dict or list. " FILTERX_FUNC_UNSET_EMPTIES_USAGE, s, obj);
254247
filterx_object_unref(obj);
255-
return NULL;
248+
return success ? filterx_boolean_new(TRUE) : NULL;
256249
}
257250

258251
static void

0 commit comments

Comments
 (0)