diff options
| author | bors <bors@rust-lang.org> | 2019-06-05 12:46:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-05 12:46:15 +0000 |
| commit | 2a1d6c83d3158861ee028b26c531e5e2c7c68140 (patch) | |
| tree | 791f3846d3a18ed9b7a9e4413385f717557c1e3b /src/libsyntax | |
| parent | 817d2feb13dd1faad47ec699cd473b8be2093ec9 (diff) | |
| parent | 4c9ecbf3d1a0fdac1d97c77783685c6281136c0b (diff) | |
| download | rust-2a1d6c83d3158861ee028b26c531e5e2c7c68140.tar.gz rust-2a1d6c83d3158861ee028b26c531e5e2c7c68140.zip | |
Auto merge of #61484 - nnethercote:avoid-more-hygiene-lookups, r=petrochenkov
Avoid more hygiene lookups Mostly by combining multiple `HygieneData::with` calls into a single call on hot paths. r? @petrochenkov
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index dafa4d5c3ec..39fcd29e1b0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2083,13 +2083,6 @@ impl<'a> Parser<'a> { hi = path.span; return Ok(self.mk_expr(lo.to(hi), ExprKind::Path(Some(qself), path), attrs)); } - if self.span.rust_2018() && self.check_keyword(kw::Async) { - return if self.is_async_block() { // check for `async {` and `async move {` - self.parse_async_block(attrs) - } else { - self.parse_lambda_expr(attrs) - }; - } if self.check_keyword(kw::Move) || self.check_keyword(kw::Static) { return self.parse_lambda_expr(attrs); } @@ -2161,6 +2154,16 @@ impl<'a> Parser<'a> { assert!(self.eat_keyword(kw::Try)); return self.parse_try_block(lo, attrs); } + + // Span::rust_2018() is somewhat expensive; don't get it repeatedly. + let is_span_rust_2018 = self.span.rust_2018(); + if is_span_rust_2018 && self.check_keyword(kw::Async) { + return if self.is_async_block() { // check for `async {` and `async move {` + self.parse_async_block(attrs) + } else { + self.parse_lambda_expr(attrs) + }; + } if self.eat_keyword(kw::Return) { if self.token.can_begin_expr() { let e = self.parse_expr()?; @@ -2196,7 +2199,7 @@ impl<'a> Parser<'a> { db.span_label(self.span, "expected expression"); db.note("variable declaration using `let` is a statement"); return Err(db); - } else if self.span.rust_2018() && self.eat_keyword(kw::Await) { + } else if is_span_rust_2018 && self.eat_keyword(kw::Await) { let (await_hi, e_kind) = self.parse_await_macro_or_alt(lo, self.prev_span)?; hi = await_hi; ex = e_kind; |
