From cad617bba054334e2172b9ef54f2ed82c6067794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 15 Mar 2021 10:15:08 +0100 Subject: some clippy::performance fixes use vec![] instead of Vec::new() + push() avoid redundant clones use chars instead of &str for single char patterns in ends_with() and starts_with() allocate some Vecs with capacity to avoid unneccessary resizing --- crates/hir/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index eb1cd66fb..caa760d21 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -266,8 +266,7 @@ impl ModuleDef { } pub fn canonical_path(&self, db: &dyn HirDatabase) -> Option { - let mut segments = Vec::new(); - segments.push(self.name(db)?.to_string()); + let mut segments = vec![self.name(db)?.to_string()]; for m in self.module(db)?.path_to_root(db) { segments.extend(m.name(db).map(|it| it.to_string())) } -- cgit v1.2.3