Skip to content

Commit

Permalink
dag: rename binary_search_by to bsearch_by
Browse files Browse the repository at this point in the history
Summary:
The name is being taken by stdlib:

  warning: a method with this name may be added to the standard library in the future
     --> eden/scm/lib/dag/src/spanset.rs:228:14
      |
  228 |             .binary_search_by(|probe| span.low.cmp(&probe.low))
      |              ^^^^^^^^^^^^^^^^
      |
      = note: `#[warn(unstable_name_collisions)]` on by default
      = warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior!
      = note: for more information, see issue #48919 <rust-lang/rust#48919>
      = help: call with fully qualified syntax `BinarySearchBy::binary_search_by(...)` to keep using the current method
      = help: add `#![feature(vecdeque_binary_search)]` to the crate attributes to enable `VecDeque::<T>::binary_search_by`

Reviewed By: sfilipco

Differential Revision: D26092424

fbshipit-source-id: d2cdf7d73d2f808f038817c9dc9f4c531ff643bd
  • Loading branch information
quark-zju authored and facebook-github-bot committed Jan 28, 2021
1 parent 005328c commit 1487e26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions eden/scm/lib/dag/src/bsearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub trait BinarySearchBy<T> {
/// one of the matches could be returned. If the value is not found then
/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
fn bsearch_by<F>(&self, f: F) -> Result<usize, usize>
where
F: FnMut(&T) -> Ordering;
}

impl<T> BinarySearchBy<T> for VecDeque<T> {
fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize>
fn bsearch_by<F>(&self, mut f: F) -> Result<usize, usize>
where
F: FnMut(&T) -> Ordering,
{
Expand Down
10 changes: 2 additions & 8 deletions eden/scm/lib/dag/src/spanset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,7 @@ impl SpanSet {
/// Tests if a given [`Id`] or [`Span`] is covered by this set.
pub fn contains(&self, value: impl Into<Span>) -> bool {
let span = value.into();
let idx = match self
.spans
.binary_search_by(|probe| span.low.cmp(&probe.low))
{
let idx = match self.spans.bsearch_by(|probe| span.low.cmp(&probe.low)) {
Ok(idx) => idx,
Err(idx) => idx,
};
Expand Down Expand Up @@ -467,10 +464,7 @@ impl SpanSet {
/// This is not a general purpose API, but useful for internal logic
/// like DAG descendant calculation.
pub(crate) fn intersection_span_min(&self, rhs: Span) -> Option<Id> {
let i = match self
.spans
.binary_search_by(|probe| rhs.low.cmp(&probe.high))
{
let i = match self.spans.bsearch_by(|probe| rhs.low.cmp(&probe.high)) {
Ok(idx) => idx,
Err(idx) => idx.max(1) - 1,
};
Expand Down

0 comments on commit 1487e26

Please sign in to comment.