diff options
author | Matthias Krüger <[email protected]> | 2021-03-15 09:15:08 +0000 |
---|---|---|
committer | Matthias Krüger <[email protected]> | 2021-03-15 09:19:59 +0000 |
commit | cad617bba054334e2172b9ef54f2ed82c6067794 (patch) | |
tree | 3c124ef8606b985353de946245498babe5d7c6a0 /crates/hir/src | |
parent | de360275416ca095102f2b17d6ca1de3bd091fdb (diff) |
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
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/lib.rs | 3 |
1 files changed, 1 insertions, 2 deletions
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 { | |||
266 | } | 266 | } |
267 | 267 | ||
268 | pub fn canonical_path(&self, db: &dyn HirDatabase) -> Option<String> { | 268 | pub fn canonical_path(&self, db: &dyn HirDatabase) -> Option<String> { |
269 | let mut segments = Vec::new(); | 269 | let mut segments = vec![self.name(db)?.to_string()]; |
270 | segments.push(self.name(db)?.to_string()); | ||
271 | for m in self.module(db)?.path_to_root(db) { | 270 | for m in self.module(db)?.path_to_root(db) { |
272 | segments.extend(m.name(db).map(|it| it.to_string())) | 271 | segments.extend(m.name(db).map(|it| it.to_string())) |
273 | } | 272 | } |