-
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
rustdoc-search: simplify checkPath
and sortResults
#118109
Conversation
r? @jsha (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
@@ -18,6 +18,8 @@ if (!Array.prototype.toSpliced) { | |||
// This mapping table should match the discriminants of | |||
// `rustdoc::formats::item_type::ItemType` type in Rust. | |||
const itemTypes = [ | |||
"keyword", |
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.
Took me a little while to understand why you moved these two at the start. Could you add a comment mentioning that they need to be first to be sure they are considered first (for precedence) please? Either here or in item_type.rs
, as you see fit best.
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.
That makes sense.
This comment has been minimized.
This comment has been minimized.
43078ee
to
ded9da3
Compare
This comment has been minimized.
This comment has been minimized.
ded9da3
to
614acbc
Compare
This comment has been minimized.
This comment has been minimized.
614acbc
to
f2d3394
Compare
Thanks! @bors r+ rollup |
☔ The latest upstream changes (presumably #118134) made this pull request unmergeable. Please resolve the merge conflicts. |
This computes the same result with less code by computing many of the old checks at once: * It won't enter the loop if clength > length, because then the result of length - clength will be negative and the loop conditional will fail. * i + clength will never be greater than length, because it starts out as i = length - clength, implying that i + clength equals length, and it only goes down from there. * The aborted variable is replaced with control flow.
f2d3394
to
5246eb8
Compare
This comment has been minimized.
This comment has been minimized.
The search sorting code already sorts by item type discriminant, putting things with smaller discriminants first. There was also a special case for sorting keywords and primitives earlier, and this commit removes it by giving them lower discriminants. The sorting code has another criteria where items with descriptions appear earlier than items without, and that criteria has higher priority than the item type. This shouldn't matter, though, because primitives and keywords normally only appear in the standard library, and it always gives them descriptions.
5246eb8
to
28f17d9
Compare
@bors r=GuillaumeGomez Rebased. |
…-2, r=GuillaumeGomez rustdoc-search: simplify `checkPath` and `sortResults` These two commits reduce the amount of code in search.js with no noticeable change in performance. https://notriddle.com/rustdoc-html-demo-5/profile-5/index.html
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#117972 (Add VarDebugInfo to Stable MIR) - rust-lang#118109 (rustdoc-search: simplify `checkPath` and `sortResults`) - rust-lang#118110 (Document `DefiningAnchor` a bit more) - rust-lang#118112 (Don't ICE when ambiguity is found when selecting `Index` implementation in typeck) - rust-lang#118135 (Remove quotation from filename in stable_mir) Failed merges: - rust-lang#118012 (Add support for global allocation in smir) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#118109 - notriddle:notriddle/search-cleanup-2, r=GuillaumeGomez rustdoc-search: simplify `checkPath` and `sortResults` These two commits reduce the amount of code in search.js with no noticeable change in performance. https://notriddle.com/rustdoc-html-demo-5/profile-5/index.html
These two commits reduce the amount of code in search.js with no noticeable change in performance.
https://notriddle.com/rustdoc-html-demo-5/profile-5/index.html