Skip to content

Commit

Permalink
Some minor clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dermesser committed Dec 23, 2023
1 parent 95a4f73 commit 89e6612
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/skipmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ impl InnerSkipMap {

// Insert new node by first replacing the previous element's next field with None and
// assigning its value to new.next...
new.next = unsafe { replace(&mut (*current).next, None) };
new.next = unsafe { (*current).next.take() };
// ...and then setting the previous element's next field to the new node
unsafe { replace(&mut (*current).next, Some(new)) };
unsafe { let _ = replace(&mut (*current).next, Some(new)); };
}
/// Runs through the skipmap and prints everything including addresses
fn dbg_print(&self) {
Expand All @@ -287,7 +287,7 @@ impl InnerSkipMap {
(*current).value,
(*current).skips
);
if let Some(next) = (*current).skips[0].clone() {
if let Some(next) = (*current).skips[0] {
current = next;
} else {
break;
Expand Down
9 changes: 4 additions & 5 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl Version {
let overlaps = self.overlapping_inputs(
level + 2,
start.internal_key(),
&limit.internal_key(),
limit.internal_key(),
);
let size = total_size(overlaps.iter());
if size > 10 * (2 << 20) {
Expand All @@ -195,20 +195,19 @@ impl Version {
/// record_read_sample returns true if there is a new file to be compacted. It counts the
/// number of files overlapping a key, and which level contains the first overlap.
#[allow(unused_assignments)]
pub fn record_read_sample<'a>(&mut self, key: InternalKey<'a>) -> bool {
let levels = self.get_overlapping(key);
pub fn record_read_sample(&mut self, key: InternalKey<'_>) -> bool {
let mut contained_in = 0;
let mut i = 0;
let mut first_file = None;
let mut first_file_level = None;
for level in &levels {
self.get_overlapping(key).iter().for_each(|level| {
if !level.is_empty() && first_file.is_none() && first_file_level.is_none() {
first_file = Some(level[0].clone());
first_file_level = Some(i);
}
contained_in += level.len();
i += 1;
}
});

if contained_in > 1 {
self.update_stats(GetStats {
Expand Down

0 comments on commit 89e6612

Please sign in to comment.