mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-10-26 10:57:38 +08: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:
1 parent
cad5591bc0
commit
f344930a16
1 file changed
+4
-5
@@ -1216,11 +1216,10 @@ impl Process {
|
||||
|
||||
{
|
||||
let inner = self.inner.lock();
|
||||
for (node_ptr, node) in &inner.nodes {
|
||||
if *node_ptr > ptr {
|
||||
node.populate_debug_info(&mut out, &inner);
|
||||
break;
|
||||
}
|
||||
// cursor_lower_bound retrieves the "key" passed or the next existing larger key
|
||||
if let Some(cursor) = inner.nodes.cursor_lower_bound(&(ptr + 1)) {
|
||||
let (_, node) = cursor.current();
|
||||
node.populate_debug_info(&mut out, &inner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user