Skip to content

Commit

Permalink
filterx/expr-null-coalesce: refactor to use early return
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Szakacs <[email protected]>
  • Loading branch information
alltilla committed Jan 3, 2025
1 parent a91a031 commit d746ce7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/filterx/expr-null-coalesce.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,18 @@ _optimize(FilterXExpr *s)
if (filterx_binary_op_optimize_method(s))
g_assert_not_reached();

if (filterx_expr_is_literal(self->super.lhs))
{
FilterXObject *lhs_object = filterx_expr_eval(self->super.lhs);
if (!lhs_object || filterx_object_is_type(lhs_object, &FILTERX_TYPE_NAME(null)))
{
filterx_object_unref(lhs_object);
return filterx_expr_ref(self->super.rhs);
}
if (!filterx_expr_is_literal(self->super.lhs))
return NULL;

FilterXObject *lhs_object = filterx_expr_eval(self->super.lhs);
if (!lhs_object || filterx_object_is_type(lhs_object, &FILTERX_TYPE_NAME(null)))
{
filterx_object_unref(lhs_object);
return filterx_expr_ref(self->super.lhs);
return filterx_expr_ref(self->super.rhs);
}

return NULL;
filterx_object_unref(lhs_object);
return filterx_expr_ref(self->super.lhs);
}

FilterXExpr *
Expand Down

0 comments on commit d746ce7

Please sign in to comment.