Add helper function to set previous element during the automerge iteration. No functional changes are intended. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- src/intervals.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/intervals.c b/src/intervals.c index 12cccbdab752..44fdda36e35f 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -148,6 +148,14 @@ static void set_sort_splice(struct expr *init, struct set *set) } } +static void set_prev_elem(struct expr **prev, struct expr *i, + struct range *prev_range, struct range *range) +{ + *prev = i; + mpz_set(prev_range->low, range->low); + mpz_set(prev_range->high, range->high); +} + static void setelem_automerge(struct set_automerge_ctx *ctx) { struct expr *i, *next, *prev = NULL; @@ -168,9 +176,7 @@ static void setelem_automerge(struct set_automerge_ctx *ctx) range_expr_value_high(range.high, i); if (!prev) { - prev = i; - mpz_set(prev_range.low, range.low); - mpz_set(prev_range.high, range.high); + set_prev_elem(&prev, i, &prev_range, &range); continue; } @@ -192,9 +198,7 @@ static void setelem_automerge(struct set_automerge_ctx *ctx) } } - prev = i; - mpz_set(prev_range.low, range.low); - mpz_set(prev_range.high, range.high); + set_prev_elem(&prev, i, &prev_range, &range); } mpz_clear(prev_range.low); -- 2.30.2