From 7e0fa715329571da8d5d551b1815303c39cf51c1 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Wed, 25 Sep 2019 10:30:33 +0900 Subject: Avoid intermediate allocation --- crates/ra_hir/src/ty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index e6ecbe1ea..fae9c1e22 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -223,7 +223,7 @@ impl Substs { } pub fn prefix(&self, n: usize) -> Substs { - Substs(self.0.iter().cloned().take(n).collect::>().into()) + Substs(self.0[..std::cmp::min(self.0.len(), n)].into()) } pub fn walk(&self, f: &mut impl FnMut(&Ty)) { -- cgit v1.2.3