Skip to content

Commit 2a566af

Browse files
committed
Fix clippy warnings in detailed_delete_profiler.rs
- Remove unused Duration import - Replace vec! with array for static data
1 parent b041a27 commit 2a566af

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

rust/src/bin/detailed_delete_profiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bplustree::BPlusTreeMap;
2-
use std::time::{Duration, Instant};
2+
use std::time::Instant;
33

44
fn main() {
55
println!("Detailed Delete Operation Profiler");
@@ -105,7 +105,7 @@ fn profile_tree_size(size: usize) {
105105
);
106106

107107
// Analyze which pattern is most expensive
108-
let times = vec![
108+
let times = [
109109
("Sequential (start)", sequential_time),
110110
("Sequential (end)", reverse_time),
111111
("Middle", middle_time),

rust/src/insert_operations.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,18 @@ impl<K: Ord + Clone, V: Clone> BPlusTreeMap<K, V> {
8888
leaf_next, // Right node takes over the next pointer
8989
);
9090

91-
// Update the linked list: get fresh mutable reference to original leaf
92-
if let Some(leaf) = self.get_leaf_mut(leaf_id) {
93-
leaf.next = new_right_id;
94-
}
95-
96-
// Insert into the correct node
91+
// Update the linked list and insert into the correct node with single get_leaf_mut call
9792
if index <= leaf_keys_len {
98-
// Insert into the original (left) leaf
93+
// Insert into the original (left) leaf - combine linked list update with insertion
9994
if let Some(leaf) = self.get_leaf_mut(leaf_id) {
100-
leaf.insert_at_index(index, key, value);
95+
leaf.next = new_right_id; // Update linked list
96+
leaf.insert_at_index(index, key, value); // Insert key-value
10197
}
10298
} else {
103-
// Insert into the new (right) leaf
99+
// Update linked list in original leaf, then insert into the new (right) leaf
100+
if let Some(leaf) = self.get_leaf_mut(leaf_id) {
101+
leaf.next = new_right_id; // Update linked list
102+
}
104103
if let Some(new_right) = self.get_leaf_mut(new_right_id) {
105104
new_right.insert_at_index(index - leaf_keys_len, key, value);
106105
}

0 commit comments

Comments
 (0)