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
This commit is contained in:
@@ -266,8 +266,7 @@ impl ModuleDef {
|
||||
}
|
||||
|
||||
pub fn canonical_path(&self, db: &dyn HirDatabase) -> Option<String> {
|
||||
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()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user