aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShotaro Yamada <[email protected]>2019-09-25 02:30:33 +0100
committerShotaro Yamada <[email protected]>2019-09-25 02:30:33 +0100
commit7e0fa715329571da8d5d551b1815303c39cf51c1 (patch)
treee3aeb7e0da92f663aa7fb710dcfe6d2e69d8026c
parentc7420ddaaa76741d1eebe393406b38ba5596e54a (diff)
Avoid intermediate allocation
-rw-r--r--crates/ra_hir/src/ty.rs2
1 files changed, 1 insertions, 1 deletions
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 {
223 } 223 }
224 224
225 pub fn prefix(&self, n: usize) -> Substs { 225 pub fn prefix(&self, n: usize) -> Substs {
226 Substs(self.0.iter().cloned().take(n).collect::<Vec<_>>().into()) 226 Substs(self.0[..std::cmp::min(self.0.len(), n)].into())
227 } 227 }
228 228
229 pub fn walk(&self, f: &mut impl FnMut(&Ty)) { 229 pub fn walk(&self, f: &mut impl FnMut(&Ty)) {