Uh oh!
There was an error while loading. Please reload this page.
search.js: split out nested functions - #91992
Conversation
`execSearch` was a giant function with a number of other very large functions embedded inside it. This moves the embedded functions out of execSearch, so execSearch's function signature can be read next to its code. `sortResults` was relying on capturing certain variables from its environment, so I made those into explicity parameters passed into `sortResults`.
rust-highfive
commented
Dec 16, 2021
Some changes occurred in HTML/CSS/JS. |
rust-log-analyzer
commented
Dec 16, 2021
The job Click to see the possible cause of the failure (guessed by this bot) |
jsha
commented
Dec 16, 2021
It looks like this runs into a problem with src/tools/rustdoc-js/tester.js. The tester doesn't actually load search.js as a module; instead it processes search.js to try and find certain functions and variables and extract them. So it's extracting execQuery but not the functions execQuery depends on. I think the fix may be to just load search.js as a module. |
GuillaumeGomez
commented
Dec 16, 2021
It's actually complicated to import Also, can you wait for #91977 to be merged first please? :) |
jsha
commented
Dec 16, 2021
Yes, definitely happy to wait for #91977, just wanted to get this idea up for a look.
Yes, this is true, but I think it's worthwhile to refactor somewhat so it doesn't need global variables. Then we can have a pure function that takes as input the corpus, a query, and some config options. That should make it simpler to test and we can remove a lot of the tester code. That will also open up the possibility of using JS code coverage tools to see what needs more testing. |
bors
commented
Dec 18, 2021
☔ The latest upstream changes (presumably #92064) made this pull request unmergeable. Please resolve the merge conflicts. |
jsha
commented
Dec 30, 2021
I'm going to close this for now since it would generate a lot of conflicts with #90630, and this is a fairly straightforward refactoring that can be applied after that PR lands. |
execSearchwas a giant function with a number of other very large functions embedded inside it. This moves the embedded functions out of execSearch, so execSearch's function signature can be read next to its code.sortResultswas relying on capturing certain variables from its environment, so I made those into explicity parameters passed intosortResults.This doesn't change any functionality. It also doesn't change any comments or parameters other than those used by
sortResults. It just moves lines from one place to another and changes indentation.Discussed on Discord.
r? @GuillaumeGomez