[PATCH nft] segtree: stop iteration on existing elements in case closing range is found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No need to keep iterating once the range object has been allocated.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/segtree.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/segtree.c b/src/segtree.c
index dc2554b72acf..dc457d6bc1b7 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.11.0




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux