rustdoc-search: simplify checkPath and sortResults#118109
Merged
bors merged 2 commits intorust-lang:masterfrom Nov 22, 2023
Merged
rustdoc-search: simplify checkPath and sortResults#118109bors merged 2 commits intorust-lang:masterfrom
checkPath and sortResults#118109bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
|
r? @jsha (rustbot has picked a reviewer for you, use r? to override) |
Collaborator
|
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
| // This mapping table should match the discriminants of | ||
| // `rustdoc::formats::item_type::ItemType` type in Rust. | ||
| const itemTypes = [ | ||
| "keyword", |
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
That makes sense.
Contributor
Author
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
GuillaumeGomez
approved these changes
Nov 21, 2023
Member
|
Thanks! @bors r+ rollup |
Collaborator
Collaborator
|
☔ 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
Contributor
Author
|
@bors r=GuillaumeGomez Rebased. |
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Nov 21, 2023
…-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
This was referenced Nov 21, 2023
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 22, 2023
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 22, 2023
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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