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_completion/src/completions/postfix/format_like.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ide_completion/src/completions/postfix/format_like.rs') diff --git a/crates/ide_completion/src/completions/postfix/format_like.rs b/crates/ide_completion/src/completions/postfix/format_like.rs index 3afc63021..cee4eec10 100644 --- a/crates/ide_completion/src/completions/postfix/format_like.rs +++ b/crates/ide_completion/src/completions/postfix/format_like.rs @@ -59,7 +59,7 @@ pub(crate) fn add_format_like_completions( /// Checks whether provided item is a string literal. fn string_literal_contents(item: &ast::String) -> Option { let item = item.text(); - if item.len() >= 2 && item.starts_with("\"") && item.ends_with("\"") { + if item.len() >= 2 && item.starts_with('\"') && item.ends_with('\"') { return Some(item[1..item.len() - 1].to_owned()); } -- cgit v1.2.3