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/ide/src/join_lines.rs | 4 ++-- crates/ide/src/typing.rs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index 20a920ddb..d571ed559 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs @@ -218,7 +218,7 @@ mod tests { let result = join_lines(&file, range); let actual = { - let mut actual = before.to_string(); + let mut actual = before; result.apply(&mut actual); actual }; @@ -622,7 +622,7 @@ fn foo() { let parse = SourceFile::parse(&before); let result = join_lines(&parse.tree(), sel); let actual = { - let mut actual = before.to_string(); + let mut actual = before; result.apply(&mut actual); actual }; diff --git a/crates/ide/src/typing.rs b/crates/ide/src/typing.rs index e3c3aebac..a718faf63 100644 --- a/crates/ide/src/typing.rs +++ b/crates/ide/src/typing.rs @@ -145,9 +145,8 @@ mod tests { use super::*; fn do_type_char(char_typed: char, before: &str) -> Option { - let (offset, before) = extract_offset(before); + let (offset, mut before) = extract_offset(before); let edit = TextEdit::insert(offset, char_typed.to_string()); - let mut before = before.to_string(); edit.apply(&mut before); let parse = SourceFile::parse(&before); on_char_typed_inner(&parse.tree(), offset, char_typed).map(|it| { -- cgit v1.2.3