aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src
diff options
context:
space:
mode:
authorMatthias Krüger <[email protected]>2021-03-15 09:15:08 +0000
committerMatthias Krüger <[email protected]>2021-03-15 09:19:59 +0000
commitcad617bba054334e2172b9ef54f2ed82c6067794 (patch)
tree3c124ef8606b985353de946245498babe5d7c6a0 /crates/mbe/src
parentde360275416ca095102f2b17d6ca1de3bd091fdb (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/mbe/src')
-rw-r--r--crates/mbe/src/syntax_bridge.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs
index aacae1026..b715ebfc4 100644
--- a/crates/mbe/src/syntax_bridge.rs
+++ b/crates/mbe/src/syntax_bridge.rs
@@ -222,14 +222,10 @@ fn convert_doc_comment(token: &syntax::SyntaxToken) -> Option<Vec<tt::TokenTree>
222 let doc = comment.kind().doc?; 222 let doc = comment.kind().doc?;
223 223
224 // Make `doc="\" Comments\"" 224 // Make `doc="\" Comments\""
225 let mut meta_tkns = Vec::new(); 225 let meta_tkns = vec![mk_ident("doc"), mk_punct('='), mk_doc_literal(&comment)];
226 meta_tkns.push(mk_ident("doc"));
227 meta_tkns.push(mk_punct('='));
228 meta_tkns.push(mk_doc_literal(&comment));
229 226
230 // Make `#![]` 227 // Make `#![]`
231 let mut token_trees = Vec::new(); 228 let mut token_trees = vec![mk_punct('#')];
232 token_trees.push(mk_punct('#'));
233 if let ast::CommentPlacement::Inner = doc { 229 if let ast::CommentPlacement::Inner = doc {
234 token_trees.push(mk_punct('!')); 230 token_trees.push(mk_punct('!'));
235 } 231 }