Filterx switch range case#1093
Conversation
Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Tamás Kosztyu <tamas.kosztyu@axoflow.com>
Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Tamás Kosztyu <tamas.kosztyu@axoflow.com>
We can't cache a range, so an early return is added too. Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Tamás Kosztyu <tamas.kosztyu@axoflow.com>
Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Tamás Kosztyu <tamas.kosztyu@axoflow.com>
| self->super.super.free_fn = _switch_case_free; | ||
| self->super.super.walk_children = _switch_case_walk; | ||
| self->super.operand = lower; | ||
| self->upper = upper; |
There was a problem hiding this comment.
This probably belongs to the previous commit.
| { | ||
| FilterXSwitchCase *self = g_new0(FilterXSwitchCase, 1); | ||
| filterx_unary_op_init_instance(&self->super, FILTERX_EXPR_TYPE_NAME(switch_case), FXE_READ, value); | ||
| self->upper = NULL; |
There was a problem hiding this comment.
We usually don't do this after g_new0.
| if (!value) | ||
| continue; | ||
| if (switch_case->upper) | ||
| { |
There was a problem hiding this comment.
Can we extract this block into an gboolean _is_switch_range_case_matching() or anything similar?
(The same can be done with the non-ranged case, but it's small enough to be left inside the else block.)
There was a problem hiding this comment.
I have been told the PR will be refactored to have an inherited "case" class, which handles ranges more elegantly; that invalidate this note.
|
We'll need a news entry for this. |
|
$.02: I like this, but depending on the use-case we might want to cache the ranged values as well, especially if those are "small", enumerable ranges (like the ones in the example). |
mitzkia
left a comment
There was a problem hiding this comment.
Thanks for the Light testcases, I can approve them.
Range is inclusive on both ends.
Example usage: