mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
rust_binder: speed up get_node_debug_info using lower_bound iter
Finding the next node in the RBTree can be done more efficiently using the cursor_lower_bound, as it reduces cost from O(n) to O(log n). Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://github.com/Rust-for-Linux/linux/issues/1249 Suggested-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Rafael Passos <rafael@rcpassos.me> Link: https://patch.msgid.link/20260814215145.2050599-1-rafael@rcpassos.me Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
cad5591bc0
commit
f344930a16
|
|
@ -1216,11 +1216,10 @@ fn get_node_debug_info(&self, data: UserSlice) -> Result {
|
||||||
|
|
||||||
{
|
{
|
||||||
let inner = self.inner.lock();
|
let inner = self.inner.lock();
|
||||||
for (node_ptr, node) in &inner.nodes {
|
// cursor_lower_bound retrieves the "key" passed or the next existing larger key
|
||||||
if *node_ptr > ptr {
|
if let Some(cursor) = inner.nodes.cursor_lower_bound(&(ptr + 1)) {
|
||||||
node.populate_debug_info(&mut out, &inner);
|
let (_, node) = cursor.current();
|
||||||
break;
|
node.populate_debug_info(&mut out, &inner);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user