Skip to content
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

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

notriddle
Copy link
Contributor

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

@rustbot
Copy link
Collaborator

rustbot commented Nov 20, 2023

r? @jsha

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 20, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 20, 2023

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",
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

@notriddle
Copy link
Contributor Author

r? @GuillaumeGomez

@rustbot rustbot assigned GuillaumeGomez and unassigned jsha Nov 20, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 21, 2023

📌 Commit f2d3394 has been approved by GuillaumeGomez

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 21, 2023
@bors
Copy link
Contributor

bors commented Nov 21, 2023

☔ The latest upstream changes (presumably #118134) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 21, 2023
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.
@rust-log-analyzer

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.
@notriddle
Copy link
Contributor Author

@bors r=GuillaumeGomez

Rebased.

@bors
Copy link
Contributor

bors commented Nov 21, 2023

📌 Commit 28f17d9 has been approved by GuillaumeGomez

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 21, 2023
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
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
@bors bors merged commit bdb929e into rust-lang:master Nov 22, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 22, 2023
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
@notriddle notriddle deleted the notriddle/search-cleanup-2 branch November 22, 2023 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants