Avoid intermediate allocation

This commit is contained in:
Shotaro Yamada 2019-09-25 10:30:33 +09:00
parent c7420ddaaa
commit 7e0fa71532

View file

@ -223,7 +223,7 @@ impl Substs {
}
pub fn prefix(&self, n: usize) -> Substs {
Substs(self.0.iter().cloned().take(n).collect::<Vec<_>>().into())
Substs(self.0[..std::cmp::min(self.0.len(), n)].into())
}
pub fn walk(&self, f: &mut impl FnMut(&Ty)) {