Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl Wal {
}

// Validate the closed segments. They must be non-overlapping, and contiguous.
closed_segments.sort_by(|a, b| a.start_index.cmp(&b.start_index));
closed_segments.sort_by_key(|a| a.start_index);
let mut next_start_index = closed_segments
.first()
.map_or(0, |segment| segment.start_index);
Expand Down Expand Up @@ -202,7 +202,7 @@ impl Wal {
}

// Validate the open segments.
open_segments.sort_by(|a, b| a.id.cmp(&b.id));
open_segments.sort_by_key(|a| a.id);

// The latest open segment, may already have segments.
let mut open_segment: Option<OpenSegment> = None;
Expand Down Expand Up @@ -272,10 +272,10 @@ impl Wal {
let start_index = self.open_segment_start_index();

// If there is an empty closed segment, remove it before adding the new one.
if let Some(last_closed) = self.closed_segments.last()
&& last_closed.segment.is_empty()
if let Some(empty_segment) = self
.closed_segments
.pop_if(|last_closed| last_closed.segment.is_empty())
{
let empty_segment = self.closed_segments.pop().unwrap();
empty_segment.segment.delete()?;
}

Expand Down
Loading