61 lines
1.5 KiB
Diff
61 lines
1.5 KiB
Diff
From d1145542184ec34ce19f383ea3d361d3287651ee Mon Sep 17 00:00:00 2001
|
|
From: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
Date: Wed, 3 Oct 2018 16:19:47 +0200
|
|
Subject: [PATCH] segtree: stop iteration on existing elements in case range is
|
|
found
|
|
|
|
No need to keep iterating once the range object has been allocated.
|
|
|
|
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
(cherry picked from commit a493147e60d350aca4197975281bf2ffe4cd1009)
|
|
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
---
|
|
src/segtree.c | 10 ++++++----
|
|
1 file changed, 6 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/segtree.c b/src/segtree.c
|
|
index dc2554b72acf3..dc457d6bc1b7d 100644
|
|
--- a/src/segtree.c
|
|
+++ b/src/segtree.c
|
|
@@ -661,16 +661,18 @@ static struct expr *get_set_interval_find(const struct table *table,
|
|
range_expr_value_low(low, i);
|
|
range_expr_value_high(high, i);
|
|
if (mpz_cmp(left->key->value, low) >= 0 &&
|
|
- mpz_cmp(right->key->value, high) <= 0)
|
|
+ mpz_cmp(right->key->value, high) <= 0) {
|
|
range = range_expr_alloc(&internal_location,
|
|
expr_clone(left->key),
|
|
expr_clone(right->key));
|
|
+ goto out;
|
|
+ }
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
+out:
|
|
mpz_clear(low);
|
|
mpz_clear(high);
|
|
|
|
@@ -697,14 +699,14 @@ static struct expr *get_set_interval_end(const struct table *table,
|
|
range = range_expr_alloc(&internal_location,
|
|
expr_clone(left->key),
|
|
expr_clone(i->key->right));
|
|
- break;
|
|
+ goto out;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
+out:
|
|
mpz_clear(low);
|
|
mpz_clear(high);
|
|
|
|
--
|
|
2.19.0
|
|
|