aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Moore <dougm@FreeBSD.org>2024-06-13 18:49:43 +0000
committerDoug Moore <dougm@FreeBSD.org>2024-06-13 18:52:25 +0000
commita7f67ebd8275165b2f6099de20790e112f8b1433 (patch)
tree54bb1f22011b520e963faf2cbe0abeda5a75da73
parentd2acf0a447093dcf0805c75490e1cd989bc8c36c (diff)
downloadsrc-a7f67ebd8275165b2f6099de20790e112f8b1433.tar.gz
src-a7f67ebd8275165b2f6099de20790e112f8b1433.zip
subr_rangeset: use pctrie_reclaim_cb in remove_all
Replace the lookup-remove loop in rangeet_remove_all with a call to SWAP_PCTRIE_RECLAIM_CALLBACK, to eliminate repeated trie searches. Reviewed by: rlibby Differential Revision: https://reviews.freebsd.org/D45584
-rw-r--r--sys/kern/subr_rangeset.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/kern/subr_rangeset.c b/sys/kern/subr_rangeset.c
index 0a675b4a2fce..94b77a449d22 100644
--- a/sys/kern/subr_rangeset.c
+++ b/sys/kern/subr_rangeset.c
@@ -232,18 +232,20 @@ rangeset_remove(struct rangeset *rs, uint64_t start, uint64_t end)
return (rangeset_remove_pred(rs, start, end, rangeset_true_pred));
}
+static void
+rangeset_remove_leaf(void *rv, void *rsv)
+{
+ struct rs_el *r = rv;
+ struct rangeset *rs = rsv;
+
+ rs->rs_free_data(rs->rs_data_ctx, r);
+}
+
void
rangeset_remove_all(struct rangeset *rs)
{
- struct rs_el *r;
-
- for (;;) {
- r = RANGESET_PCTRIE_LOOKUP_GE(&rs->rs_trie, 0);
- if (r == NULL)
- break;
- RANGESET_PCTRIE_REMOVE(&rs->rs_trie, r->re_start);
- rs->rs_free_data(rs->rs_data_ctx, r);
- }
+ RANGESET_PCTRIE_RECLAIM_CALLBACK(&rs->rs_trie,
+ rangeset_remove_leaf, rs);
}
void *