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

More js cleanup #80554

Merged
merged 2 commits into from
Jan 4, 2021
Merged

More js cleanup #80554

merged 2 commits into from
Jan 4, 2021

Conversation

GuillaumeGomez
Copy link
Member

Part of #79052 (Same kind as #80515).

This one is about some small fixes:

  • Replacing some loops with onEachLazy.
  • Removing unused function arguments.
  • Turn buildHelperPopup into a variable so it can be "replaced" once the function has been called once so it's not called again.

r? @jyn514

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Dec 31, 2020
@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 31, 2020
@jyn514 jyn514 added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Jan 3, 2021
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

Replacing some loops with onEachLazy.

What is the difference? Why is onEachLazy better?

Turn buildHelperPopup into a variable so it can be "replaced" once the function has been called once so it's not called again.

Didn't it do that already?

$ node
> function f(a) {}
undefined
> f
[Function: f]
> f = 1
1
> f
1

Why is the new code better?

src/librustdoc/html/static/main.js Outdated Show resolved Hide resolved
src/librustdoc/html/static/main.js Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

Replacing some loops with onEachLazy.

What is the difference? Why is onEachLazy better?

It's not generally better so to speak. I wrote onEachLzay because on chrome, when you use elements iterators (such as document.getElementsByTagName("a"), if you don't store the whole iterator into a vector, it has disastrous performance. I think the explanation was that the browser was rebuilding the iterator every X items you iterate through or if the DOM was updated. In both cases, since we don't care about the new elements, we can simply store the iterator into an array and avoid this issue.

Turn buildHelperPopup into a variable so it can be "replaced" once the function has been called once so it's not called again.

Didn't it do that already?

$ node
> function f(a) {}
undefined
> f
[Function: f]
> f = 1
1
> f
1

Why is the new code better?

Not better, just more clear (at least for me). I can remove this commit if you prefer?

@jyn514
Copy link
Member

jyn514 commented Jan 3, 2021

Not better, just more clear (at least for me). I can remove this commit if you prefer?

Yes, I think I prefer the old code. Thanks.

r=me with that done

@GuillaumeGomez
Copy link
Member Author

@bors: r=jyn514 rollup

@bors
Copy link
Contributor

bors commented Jan 3, 2021

📌 Commit 8b6304e has been approved by jyn514

@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 Jan 3, 2021
@bors
Copy link
Contributor

bors commented Jan 4, 2021

⌛ Testing commit 8b6304e with merge 0cd459f...

@bors
Copy link
Contributor

bors commented Jan 4, 2021

☀️ Test successful - checks-actions
Approved by: jyn514
Pushing 0cd459f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 4, 2021
@bors bors merged commit 0cd459f into rust-lang:master Jan 4, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 4, 2021
@GuillaumeGomez GuillaumeGomez deleted the more-js-cleanup branch January 4, 2021 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. merged-by-bors This PR was explicitly merged by bors. 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.

5 participants