about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/errors.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-07-12 12:56:58 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-07-12 13:33:38 +1000
commitebe1305b1e0bb32913b309ce65bd97106532ad6a (patch)
tree4985a6bc9036fd78b587388a869e76702f248e10 /compiler/rustc_codegen_llvm/src/errors.rs
parentdad95578b0f000807f23fe2d37ca37ea8bd8522c (diff)
downloadrust-ebe1305b1e0bb32913b309ce65bd97106532ad6a.tar.gz
rust-ebe1305b1e0bb32913b309ce65bd97106532ad6a.zip
Remove the bogus special case from `Parser::look_ahead`.
The general case at the bottom of `look_ahead` is slow, because it
clones the token cursor. Above it there is a special case for
performance that is hit most of the time and avoids the cloning.
Unfortunately, its behaviour differs from the general case in two ways.

- When within a pair of delimiters, if you look any distance past the
  closing delimiter you get the closing delimiter instead of what comes
  after the closing delimiter.

- It uses `tree_cursor.look_ahead(dist - 1)` which totally confuses
  tokens with token trees. This means that only the first token in a
  token tree will be seen. E.g. in a sequence like `{ a }` the `a` and
  `}` will be skipped over. Bad!

It's likely that these differences weren't noticed before now because
the use of `look_ahead` in the parser is limited to small distances and
relatively few contexts.

Removing the special case causes slowdowns up of to 2% on a range of
benchmarks. The next commit will add a new, correct special case to
regain that lost performance.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions