From e860b9cd24ba7555c0aba8e850985c30a837335e Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 18 Mar 2024 13:39:35 -0700 Subject: [PATCH] Use promise.all to load sorted results in parallel --- src/librustdoc/html/static/js/search.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 2732d6b15436d..15da5bf96b2ca 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -2485,10 +2485,15 @@ function initSearch(rawSearchIndex) { innerRunQuery(); } + const [sorted_in_args, sorted_returned, sorted_others] = await Promise.all([ + sortResults(results_in_args, true, currentCrate), + sortResults(results_returned, true, currentCrate), + sortResults(results_others, false, currentCrate), + ]); const ret = createQueryResults( - await sortResults(results_in_args, true, currentCrate), - await sortResults(results_returned, true, currentCrate), - await sortResults(results_others, false, currentCrate), + sorted_in_args, + sorted_returned, + sorted_others, parsedQuery); handleAliases(ret, parsedQuery.original.replace(/"/g, ""), filterCrates, currentCrate); if (parsedQuery.error !== null && ret.others.length !== 0) {