From dde1525a6fab737f74ba426a0ab4f4c1b30988af Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 7 May 2024 16:55:11 -0400 Subject: [PATCH] Replace the bisection dependency It appears unmaintained, and we can use partition_point instead: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.partition_point --- Cargo.toml | 1 - src/sparse_range.rs | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 254e0ff..7a3a6bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/sparse_range.rs b/src/sparse_range.rs index ef11a5f..720dadc 100644 --- a/src/sparse_range.rs +++ b/src/sparse_range.rs @@ -1,4 +1,3 @@ -use bisection::{bisect_left, bisect_right}; use itertools::Itertools; use std::{ fmt::{Debug, Display, Formatter}, @@ -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]; @@ -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];