turbo-persistence: use partition_point for batch lookup bounds (#100821)
Follow-up to #100620, addressing [this review comment](https://github.com/vercel/next.js/pull/100620#discussion_r4399047345). ### What? `MetaFile::batch_lookup_entry` now finds the cells inside an SST file's hash range with `partition_point` instead of `binary_search_by`. ### Why? The old code used `binary_search_by` with a comparator that never returns `Equal` (`.then(Ordering::Greater)` / `.then(Ordering::Less)`) and then took the insertion point with `.err().unwrap()`. `partition_point` states the bounds directly and is easier to read. ### How? - Start: `cells.partition_point(|&(hash, _)| hash < range.min_hash)`, the first cell with `hash >= min_hash`. - End: `cells.partition_point(|&(hash, _)| hash <= range.max_hash)`, the first cell with `hash > max_hash`. Both return the same indices as before for every input, including duplicate hashes, empty slices, and bounds at `0` or `u64::MAX`. The now unused `Ordering` import is removed. There is no behavior change. <!-- NEXT_JS_LLM --> <!-- fleet 2e9e7c99-0cc2-4e7b-9e62-627c0627638b --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment