Skip to content

rustdoc: make srcIndex no longer a global variable #142100

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lolbinarycat
Copy link
Contributor

@lolbinarycat lolbinarycat commented Jun 5, 2025

this is one-time initialization data, it can just
be a function parameter.

while we're doing that, we can more the json parsing into the function and save a few extra bytes of storage for free, at least in the case of multiple crates in a doc bundle.

fixes #138467

@rustbot
Copy link
Collaborator

rustbot commented Jun 5, 2025

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot
Copy link
Collaborator

rustbot commented Jun 5, 2025

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha, @lolbinarycat

Some changes occurred in GUI tests.

cc @GuillaumeGomez

@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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 5, 2025
@rust-log-analyzer

This comment has been minimized.

this is one-time initialization data, it can just
be a function parameter.

we also move the json parsing into createSrcSidebar
to save a few bytes.
@lolbinarycat lolbinarycat force-pushed the rustdoc-srcIndex-138467 branch from 80d65ae to 1f4435a Compare June 5, 2025 23:57
@GuillaumeGomez
Copy link
Member

Seems good to me, thanks! Please remove the left-over debugging and then I'll approve.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this exist? searchIndex isn't part of the intended external interface, either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean, at least the search index is something we actually want to persist, but I suppose it could just live in a closure upvar instead of a global.

The results table needs to be public for integration testing, although i'm not sure if the same is true of searchIndex (it's definitely not true for srcIndex, I checked)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

src-script.js: make srcIndex into a parameter instead of a global variable
6 participants