Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove all 4 RC clones in min_candidates. allowing it to be inlined #5625

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/cargo/core/resolver/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::collections::{HashMap, HashSet};
use std::ops::Range;
use std::rc::Rc;

use core::{Dependency, PackageId, PackageIdSpec, Registry, Summary};
use core::interning::InternedString;
use core::{Dependency, PackageId, PackageIdSpec, Registry, Summary};
use util::{CargoError, CargoResult};

pub struct RegistryQueryer<'a> {
Expand Down Expand Up @@ -200,13 +200,12 @@ impl DepsFrame {
/// candidates in that entry.
fn min_candidates(&self) -> usize {
self.remaining_siblings
.clone()
.next()
.peek()
.map(|(_, (_, candidates, _))| candidates.len())
.unwrap_or(0)
}

pub fn flatten<'s>(&'s self) -> impl Iterator<Item=(&PackageId, Dependency)> + 's {
pub fn flatten<'s>(&'s self) -> impl Iterator<Item = (&PackageId, Dependency)> + 's {
self.remaining_siblings
.clone()
.map(move |(_, (d, _, _))| (self.parent.package_id(), d))
Expand Down Expand Up @@ -315,6 +314,13 @@ impl<T> RcVecIter<T> {
vec,
}
}

fn peek(&self) -> Option<(usize, &T)> {
self.rest
.clone()
.next()
.and_then(|i| self.vec.get(i).map(|val| (i, &*val)))
}
}

// Not derived to avoid `T: Clone`
Expand All @@ -333,7 +339,7 @@ where
{
type Item = (usize, T);

fn next(&mut self) -> Option<(usize, T)> {
fn next(&mut self) -> Option<Self::Item> {
self.rest
.next()
.and_then(|i| self.vec.get(i).map(|val| (i, val.clone())))
Expand Down