Skip to content

Commit

Permalink
filterx-unset-empties: refactor eval()
Browse files Browse the repository at this point in the history
Signed-off-by: László Várady <laszlo.varady@anno.io>
  • Loading branch information
MrAnno committed Oct 29, 2024
1 parent 9dcb329 commit 699c32c
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/filterx/func-unset-empties.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 699c32c

Please sign in to comment.