-
Notifications
You must be signed in to change notification settings - Fork 13.3k
expand: Use Option
instead of SmallVec<1>
where possible.
#141273
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
base: master
Are you sure you want to change the base?
Conversation
For most of the AST fragment kinds involved in expansion, we use `SmallVec<[T; 1]>` for the type produced. This is necessary for things like items and statements, but for many other things like arms, variants, and params, we never produce more than one, so an `Option` is sufficient. Specifics: - Numerous `flat_map_foo` methods that currently return a `SmallVec` are renamed as `filter_map_foo` and now return an `Option`. (This mirrors the existing `filter_map_expr`.) - Likewise, numerous plural `make_foos` methods that are also renamed as singular `make_foo`. - Also, various AST fragment kinds are renamed from plural to singular. - The `ast_fragments!` macro gets a new `option` kind, to augment the existing `one` and `many` kinds. - `visit_clobber_opt` is added. It's similar to `visit_clobber`. - In `expect_from_annotables`, it now checks that there aren't any excess elements in the iterator. - The associated type `InvocationCollectorNode::OutputTy` no longer has a default value, because it now varies more. It used to mostly be `SmallVec`, but not it is sometimes `SmallVec`, sometimes `Option`, and sometimes something else.
`mut_visit.rs` has a single mfunction with a `noop_` prefix: `noop_filter_map_expr`. This commit renames as `walk_filter_map_expr` which is consistent with other functions in this file. The commit also removes out-of-date comments that refer to `noop_*` methods.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…<try> expand: Use `Option` instead of `SmallVec<1>` where possible. r? `@ghost`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (7285814): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -4.2%, secondary -1.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -2.8%, secondary 0.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary -1.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 775.977s -> 775.491s (-0.06%) |
Looks to be perf-neutral. |
Currently we use
SmallVec
in various places in expansion where anOption
would suffice.r? @petrochenkov