-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tweak nearest_common_ancestor()
.
#50649
Tweak nearest_common_ancestor()
.
#50649
Conversation
- Remove the "no nearest common ancestor found" case, because it's never hit in practise. (This means `closure_is_enclosed_by` can also be removed.) - Add a comment about why `SmallVec` is used for the "seen" structures. - Use `&Scope` instead of `Scope` to avoid some `map()` calls. - Use `any(p)` instead of `position(p).is_some()`.
let mut mb = Some(&scope_b); | ||
|
||
// A HashSet<Scope> is a more obvious choice for these, but SmallVec is | ||
// faster because the set size is normally small so linear search is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you verify this? It sounds like it should be true but I've run into some surprises because FxHashSet
is so fast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did verify it. The difference was small but noticeable.
@bors r+ 🍑 |
📌 Commit a91f6f7 has been approved by |
@bors rollup |
…cestor, r=nikomatsakis Tweak `nearest_common_ancestor()`. - Remove the "no nearest common ancestor found" case, because it's never hit in practise. (This means `closure_is_enclosed_by` can also be removed.) - Add a comment about why `SmallVec` is used for the "seen" structures. - Use `&Scope` instead of `Scope` to avoid some `map()` calls. - Use `any(p)` instead of `position(p).is_some()`. r? @nikomatsakis
Rollup of 10 pull requests Successful merges: - #50387 (Remove leftover tab in libtest outputs) - #50553 (Add Option::xor method) - #50610 (Improve format string errors) - #50649 (Tweak `nearest_common_ancestor()`.) - #50790 (Fix grammar documentation wrt Unicode identifiers) - #50791 (Fix null exclusions in grammar docs) - #50806 (Add `bless` x.py subcommand for easy ui test replacement) - #50818 (Speed up `opt_normalize_projection_type`) - #50837 (Revert #49767) - #50839 (Make sure people know the book is free oline) Failed merges:
Remove `ScopeTree::closure_tree` Seems to be dead code since rust-lang#50649.
Remove `ScopeTree::closure_tree` Seems to be dead code since rust-lang#50649.
Remove the "no nearest common ancestor found" case, because it's never
hit in practise. (This means
closure_is_enclosed_by
can also beremoved.)
Add a comment about why
SmallVec
is used for the "seen" structures.Use
&Scope
instead ofScope
to avoid somemap()
calls.Use
any(p)
instead ofposition(p).is_some()
.r? @nikomatsakis