Blame SOURCES/0026-segtree-Use-expr_clone-in-get_set_interval_.patch

3e48d9
From 119fbcbd8c37aac314d6ffa6225ab24ee4b0e31e Mon Sep 17 00:00:00 2001
3e48d9
From: Phil Sutter <psutter@redhat.com>
3e48d9
Date: Tue, 30 Jun 2020 16:20:23 +0200
3e48d9
Subject: [PATCH] segtree: Use expr_clone in get_set_interval_*()
3e48d9
3e48d9
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1832235
3e48d9
Upstream Status: nftables commit a2eedcc89d2ed
3e48d9
3e48d9
commit a2eedcc89d2ed40411c26d53579300c4f1ccb83d
3e48d9
Author: Phil Sutter <phil@nwl.cc>
3e48d9
Date:   Thu Apr 30 13:45:40 2020 +0200
3e48d9
3e48d9
    segtree: Use expr_clone in get_set_interval_*()
3e48d9
3e48d9
    Both functions perform interval set lookups with either start and end or
3e48d9
    only start values as input. Interestingly, in practice they either see
3e48d9
    values which are not contained or which match an existing range exactly.
3e48d9
3e48d9
    Make use of the above and just return a clone of the matching entry
3e48d9
    instead of creating a new one based on input data.
3e48d9
3e48d9
    Signed-off-by: Phil Sutter <phil@nwl.cc>
3e48d9
---
3e48d9
 src/segtree.c | 8 ++------
3e48d9
 1 file changed, 2 insertions(+), 6 deletions(-)
3e48d9
3e48d9
diff --git a/src/segtree.c b/src/segtree.c
3e48d9
index 1ba4363..dc4db6b 100644
3e48d9
--- a/src/segtree.c
3e48d9
+++ b/src/segtree.c
3e48d9
@@ -695,9 +695,7 @@ static struct expr *get_set_interval_find(const struct table *table,
3e48d9
 			range_expr_value_high(high, i);
3e48d9
 			if (mpz_cmp(left->key->value, low) >= 0 &&
3e48d9
 			    mpz_cmp(right->key->value, high) <= 0) {
3e48d9
-				range = range_expr_alloc(&internal_location,
3e48d9
-							 expr_clone(left->key),
3e48d9
-							 expr_clone(right->key));
3e48d9
+				range = expr_clone(i->key);
3e48d9
 				goto out;
3e48d9
 			}
3e48d9
 			break;
3e48d9
@@ -729,9 +727,7 @@ static struct expr *get_set_interval_end(const struct table *table,
3e48d9
 		case EXPR_RANGE:
3e48d9
 			range_expr_value_low(low, i);
3e48d9
 			if (mpz_cmp(low, left->key->value) == 0) {
3e48d9
-				range = range_expr_alloc(&internal_location,
3e48d9
-							 expr_clone(left->key),
3e48d9
-							 expr_clone(i->key->right));
3e48d9
+				range = expr_clone(i->key);
3e48d9
 				goto out;
3e48d9
 			}
3e48d9
 			break;
3e48d9
-- 
252916
2.31.1
3e48d9