mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-08-24 06:58:16 +00:00
kvm tools: rb_int_search_single simplification
As the rbtree intervals are not overlapping, rb_int_search_single can trivially be implemented without making use of the max_high field. Signed-off-by: Michel Lespinasse <walken@google.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
3e64a4a462
commit
ffc83de357
+5
-13
@@ -5,27 +5,19 @@
|
||||
struct rb_int_node *rb_int_search_single(struct rb_root *root, u64 point)
|
||||
{
|
||||
struct rb_node *node = root->rb_node;
|
||||
struct rb_node *lowest = NULL;
|
||||
|
||||
while (node) {
|
||||
struct rb_int_node *cur = rb_int(node);
|
||||
|
||||
if (node->rb_left && (rb_int(node->rb_left)->max_high > point)) {
|
||||
if (point < cur->low)
|
||||
node = node->rb_left;
|
||||
} else if (cur->low <= point && cur->high > point) {
|
||||
lowest = node;
|
||||
break;
|
||||
} else if (point > cur->low) {
|
||||
else if (cur->high <= point)
|
||||
node = node->rb_right;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
else
|
||||
return cur;
|
||||
}
|
||||
|
||||
if (lowest == NULL)
|
||||
return NULL;
|
||||
|
||||
return rb_int(lowest);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct rb_int_node *rb_int_search_range(struct rb_root *root, u64 low, u64 high)
|
||||
|
||||
Reference in New Issue
Block a user