]> git.lizzy.rs Git - rust.git/commitdiff
Remove some unneeded string allocations
authorLukas Wirth <lukastw97@gmail.com>
Thu, 31 Dec 2020 09:13:14 +0000 (10:13 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Thu, 31 Dec 2020 09:13:14 +0000 (10:13 +0100)
crates/completion/src/completions/attribute.rs
crates/hir_def/src/nameres.rs
crates/ssr/src/matching.rs

index 19ce2482fd4babf364e2dcdd42754a7e445a0b76..8695eed3984096068b1be09b6bd0e44df1360df0 100644 (file)
@@ -234,7 +234,7 @@ fn parse_comma_sep_input(derive_input: ast::TokenTree) -> Result<FxHashSet<Strin
                         current_derive = String::new();
                     }
                 } else {
-                    current_derive.push_str(token.to_string().trim());
+                    current_derive.push_str(token.text().trim());
                 }
             }
 
index 9bf358775958a17a5c8c2f9d49cc96c6e7793724..5682e122dbd7c5d5b8a7e66b1c785c61769fe097 100644 (file)
@@ -454,7 +454,7 @@ pub(super) fn add_to(
                                     });
                                 for token in tokens {
                                     if token.kind() == SyntaxKind::IDENT
-                                        && token.to_string() == *name
+                                        && token.text() == name.as_str()
                                     {
                                         precise_location = Some(token.text_range());
                                         break 'outer;
index 99b187311a793936d1df3b1e9d08f2d05052de27..6cf8314317e064131b45319e5aaa32af62abe086 100644 (file)
@@ -473,7 +473,9 @@ fn attempt_match_token_tree(
                         }
                         SyntaxElement::Node(n) => {
                             if let Some(first_token) = n.first_token() {
-                                if Some(first_token.to_string()) == next_pattern_token {
+                                if Some(first_token.text().as_str())
+                                    == next_pattern_token.as_deref()
+                                {
                                     if let Some(SyntaxElement::Node(p)) = pattern.next() {
                                         // We have a subtree that starts with the next token in our pattern.
                                         self.attempt_match_token_tree(phase, &p, &n)?;