Skip to content

Commit

Permalink
Replace the bisection dependency
Browse files Browse the repository at this point in the history
It appears unmaintained, and we can use partition_point instead:
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.partition_point
  • Loading branch information
musicinmybrain committed May 7, 2024
1 parent f65c0c9 commit dde1525
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exclude = ["test-data/*"]
futures = "0.3.28"
http-content-range = "0.1.2"
itertools = "0.12.1"
bisection = "0.1.0"
memmap2 = "0.9.0"
reqwest = { version = "0.12.3", default-features = false, features = ["stream"] }
reqwest-middleware = "0.3.0"
Expand Down
9 changes: 4 additions & 5 deletions src/sparse_range.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bisection::{bisect_left, bisect_right};
use itertools::Itertools;
use std::{
fmt::{Debug, Display, Formatter},
Expand Down Expand Up @@ -55,8 +54,8 @@ impl SparseRange {
let range_end = range.end - 1;

// Compute the indices of the ranges that are covered by the request
let left_index = bisect_left(&self.right, &range_start);
let right_index = bisect_right(&self.left, &(range_end + 1));
let left_index = self.right.partition_point(|x| x < &range_start);
let right_index = self.left.partition_point(|x| x <= &(range_end + 1));

// Get all the range bounds that are covered
let left_slice = &self.left[left_index..right_index];
Expand Down Expand Up @@ -97,8 +96,8 @@ impl SparseRange {
let range_end = range.end - 1;

// Compute the indices of the ranges that are covered by the request
let left_index = bisect_left(&self.right, &range_start);
let right_index = bisect_right(&self.left, &(range_end + 1));
let left_index = self.right.partition_point(|x| x < &range_start);
let right_index = self.left.partition_point(|x| x <= &(range_end + 1));

// Get all the range bounds that are covered
let left_slice = &self.left[left_index..right_index];
Expand Down

0 comments on commit dde1525

Please sign in to comment.