-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parser: Cleanup LazyTokenStream
and avoid some clones
#78587
Conversation
by using a named struct instead of a closure.
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit d0c63bc with merge 99e4ef7ba85e18068c4232297da28acab7db20f6... |
☀️ Try build successful - checks-actions |
Queued 99e4ef7ba85e18068c4232297da28acab7db20f6 with parent ffe5288, future comparison URL. |
Finished benchmarking try commit (99e4ef7ba85e18068c4232297da28acab7db20f6): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
It looks like adding a @bors r+ |
📌 Commit d0c63bc has been approved by |
@bors rollup- |
Rollup of 7 pull requests Successful merges: - rust-lang#74622 (Add std::panic::panic_any.) - rust-lang#77099 (make exp_m1 and ln_1p examples more representative of use) - rust-lang#78526 (Strip tokens from trait and impl items before printing AST JSON) - rust-lang#78550 (x.py setup: Create config.toml in the current directory, not the top-level directory) - rust-lang#78577 (validator: Extend aliasing check to a call terminator) - rust-lang#78581 (Constantify more BTreeMap and BTreeSet functions) - rust-lang#78587 (parser: Cleanup `LazyTokenStream` and avoid some clones) Failed merges: r? `@ghost`
@Aaron1011 The second reason for introducing an enum is that using The problem is that the requirement
Perhaps if 16 byte is significantly better in terms of allocations and cloning, it will compensate... I need to check. |
Since Lazytokenstream is heap allocated, you might consider bit packing the discriminant (by increasing alignment slightly); there's some helpers available in rustc data structures to do so somewhat easily. Unfortunately it's unlikely to be an ergonomic thing as you definitely lose matching and such. |
Some statistics of token stream lengths in
So, optimizing for 1-token streams is important, and optimizing for 0-token streams is not too important. |
by using a named struct instead of a closure.
r? @Aaron1011