about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-04-11 19:56:41 +0800
committerGitHub <noreply@github.com>2018-04-11 19:56:41 +0800
commit77777b4528827af7044c987f4f291775fd7a5b0b (patch)
tree2031d41d5e9b5463e4bc328e9fabc6fdf1eb92cc /src/libsyntax/parse
parentca26ef321c44358404ef788d315c4557eb015fb2 (diff)
parente7aa1397ea901e50cc3427d8db44c0b387253bba (diff)
downloadrust-77777b4528827af7044c987f4f291775fd7a5b0b.tar.gz
rust-77777b4528827af7044c987f4f291775fd7a5b0b.zip
Rollup merge of #49525 - varkor:sort_by_cached_key-conversion, r=scottmcm
Use sort_by_cached_key where appropriate

A follow-up to https://github.com/rust-lang/rust/pull/48639, converting various slice sorting calls to `sort_by_cached_key` when the key functions are more expensive.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 61de50e8e6a..027b24cbbdc 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -689,7 +689,7 @@ impl<'a> Parser<'a> {
                 .chain(inedible.iter().map(|x| TokenType::Token(x.clone())))
                 .chain(self.expected_tokens.iter().cloned())
                 .collect::<Vec<_>>();
-            expected.sort_by(|a, b| a.to_string().cmp(&b.to_string()));
+            expected.sort_by_cached_key(|x| x.to_string());
             expected.dedup();
             let expect = tokens_to_string(&expected[..]);
             let actual = self.this_token_to_string();