Skip to content

src-script.js: make srcIndex into a parameter instead of a global variable #138467

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

Closed
lolbinarycat opened this issue Mar 13, 2025 · 1 comment · Fixed by #142100
Closed

src-script.js: make srcIndex into a parameter instead of a global variable #138467

lolbinarycat opened this issue Mar 13, 2025 · 1 comment · Fixed by #142100
Assignees
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) A-technical-debt Area: Internal cleanup work C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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.

Comments

@lolbinarycat
Copy link
Contributor

as far as I can tell, this is only used in createSrcSidebar, which is called in generated code like this:

var srcIndex = new Map(JSON.parse('[["test123",["",[],["test123.rs"]]]]'));
createSrcSidebar();

instead, we could have generated code like this:

let srcIndex = new Map(JSON.parse('[["test123",["",[],["test123.rs"]]]]'));
createSrcSidebar(srcIndex);
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 13, 2025
@lolbinarycat lolbinarycat added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-rustdoc-ui Area: Rustdoc UI (generated HTML) A-technical-debt Area: Internal cleanup work and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 13, 2025
@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Mar 13, 2025
@lolbinarycat lolbinarycat self-assigned this Mar 13, 2025
@fmease fmease added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jun 4, 2025
@lolbinarycat
Copy link
Contributor Author

Working on this now. This should slightly reduce rustdoc's idle memory usage because we won't have a global variable floating around holding data used for one-time initialization.

workingjubilee added a commit to workingjubilee/rustc that referenced this issue Jun 17, 2025
…67, r=GuillaumeGomez

rustdoc: make srcIndex no longer a global variable

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 rust-lang#138467
@bors bors closed this as completed in 0772ee7 Jun 18, 2025
rust-timer added a commit that referenced this issue Jun 18, 2025
Rollup merge of #142100 - lolbinarycat:rustdoc-srcIndex-138467, r=GuillaumeGomez

rustdoc: make srcIndex no longer a global variable

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) A-technical-debt Area: Internal cleanup work C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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 a pull request may close this issue.

3 participants