From ae0509ab811c441ffb0e17a3d8c741b1d0767269 Mon Sep 17 00:00:00 2001 From: konstin Date: Wed, 11 Mar 2026 23:08:04 +0100 Subject: [PATCH] Migrate off bisect The repo for `bisection` was deleted: https://github.com/SteadBytes/bisection. This PR migrates of off it. --- Cargo.lock | 7 ------- Cargo.toml | 1 - src/sparse_range.rs | 9 ++++----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11f7b9f..e4a06d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,7 +60,6 @@ dependencies = [ "astral-reqwest-middleware", "async_zip", "axum", - "bisection", "futures", "http-content-range", "itertools", @@ -184,12 +183,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bisection" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021e079a1bab0ecce6cf4b4b74c0c37afa4a697136eb3b127875c84a8f04a8c3" - [[package]] name = "bitflags" version = "2.6.0" diff --git a/Cargo.toml b/Cargo.toml index 070ded6..e2858f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ name = "async_http_range_reader" futures = "0.3.28" http-content-range = "0.2.0" itertools = "0.14.0" -bisection = "0.1.0" memmap2 = "0.9.0" reqwest = { version = "0.13.1", default-features = false, features = ["stream"] } reqwest-middleware = { version = "0.5.1", package = "astral-reqwest-middleware" } diff --git a/src/sparse_range.rs b/src/sparse_range.rs index ef11a5f..12d65d5 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(|&e| e < range_start); + let right_index = self.left.partition_point(|&e| e <= 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(|&e| e < range_start); + let right_index = self.left.partition_point(|&e| e <= range_end + 1); // Get all the range bounds that are covered let left_slice = &self.left[left_index..right_index];