Don't collect() when size_hint is useless
This commit is contained in:
parent
7e8ca9f8bd
commit
b68b3965a2
@ -151,12 +151,14 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||||||
debug!("process_registered_region_obligations()");
|
debug!("process_registered_region_obligations()");
|
||||||
|
|
||||||
// pull out the region obligations with the given `body_id` (leaving the rest)
|
// pull out the region obligations with the given `body_id` (leaving the rest)
|
||||||
let my_region_obligations = {
|
let mut my_region_obligations = Vec::with_capacity(self.region_obligations.borrow().len());
|
||||||
|
{
|
||||||
let mut r_o = self.region_obligations.borrow_mut();
|
let mut r_o = self.region_obligations.borrow_mut();
|
||||||
let my_r_o = r_o.drain_filter(|(ro_body_id, _)| *ro_body_id == body_id)
|
my_region_obligations.extend(
|
||||||
.map(|(_, obligation)| obligation).collect::<Vec<_>>();
|
r_o.drain_filter(|(ro_body_id, _)| *ro_body_id == body_id)
|
||||||
my_r_o
|
.map(|(_, obligation)| obligation)
|
||||||
};
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let outlives = &mut TypeOutlives::new(
|
let outlives = &mut TypeOutlives::new(
|
||||||
self,
|
self,
|
||||||
|
@ -210,7 +210,12 @@ impl<A> Decodable for SmallVec<A>
|
|||||||
A::Element: Decodable {
|
A::Element: Decodable {
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<SmallVec<A>, D::Error> {
|
fn decode<D: Decoder>(d: &mut D) -> Result<SmallVec<A>, D::Error> {
|
||||||
d.read_seq(|d, len| {
|
d.read_seq(|d, len| {
|
||||||
(0..len).map(|i| d.read_seq_elt(i, |d| Decodable::decode(d))).collect()
|
let mut vec = SmallVec::with_capacity(len);
|
||||||
|
// FIXME(#48994) - could just be collected into a Result<SmallVec, D::Error>
|
||||||
|
for i in 0..len {
|
||||||
|
vec.push(d.read_seq_elt(i, |d| Decodable::decode(d))?);
|
||||||
|
}
|
||||||
|
Ok(vec)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,11 @@ impl Pat {
|
|||||||
PatKind::Slice(pats, None, _) if pats.len() == 1 =>
|
PatKind::Slice(pats, None, _) if pats.len() == 1 =>
|
||||||
pats[0].to_ty().map(TyKind::Slice)?,
|
pats[0].to_ty().map(TyKind::Slice)?,
|
||||||
PatKind::Tuple(pats, None) => {
|
PatKind::Tuple(pats, None) => {
|
||||||
let tys = pats.iter().map(|pat| pat.to_ty()).collect::<Option<Vec<_>>>()?;
|
let mut tys = Vec::with_capacity(pats.len());
|
||||||
|
// FIXME(#48994) - could just be collected into an Option<Vec>
|
||||||
|
for pat in pats {
|
||||||
|
tys.push(pat.to_ty()?);
|
||||||
|
}
|
||||||
TyKind::Tup(tys)
|
TyKind::Tup(tys)
|
||||||
}
|
}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user