Skip to content

Commit 6a2d74b

Browse files
authored
Unrolled build for #146070
Rollup merge of #146070 - notriddle:skip-loading-function-data, r=GuillaumeGomez rustdoc-search: skip loading unneeded fnData Fixes #146063 (probably) Based on the test I ran, it seems like most of the CPU time is being spent loading function signature data. This PR should avoid that. https://notriddle.com/rustdoc-html-demo-12/skip-loading-function-data/doc/std/index.html
2 parents a2c8b0b + ac89fcb commit 6a2d74b

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/librustdoc/html/static/js/rustdoc.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ declare namespace rustdoc {
289289
exactModulePath: string,
290290
entry: EntryData?,
291291
path: PathData?,
292-
type: FunctionData?,
292+
functionData: FunctionData?,
293293
deprecated: boolean,
294294
parent: { path: PathData, name: string}?,
295295
}

src/librustdoc/html/static/js/search.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,14 +1802,15 @@ class DocSearch {
18021802

18031803
/**
18041804
* @param {number} id
1805+
* @param {boolean} loadFunctionData
18051806
* @returns {Promise<rustdoc.Row?>}
18061807
*/
1807-
async getRow(id) {
1808-
const [name_, entry, path, type] = await Promise.all([
1808+
async getRow(id, loadFunctionData) {
1809+
const [name_, entry, path, functionData] = await Promise.all([
18091810
this.getName(id),
18101811
this.getEntryData(id),
18111812
this.getPathData(id),
1812-
this.getFunctionData(id),
1813+
loadFunctionData ? this.getFunctionData(id) : null,
18131814
]);
18141815
if (!entry && !path) {
18151816
return null;
@@ -1853,7 +1854,7 @@ class DocSearch {
18531854
`${exactModulePathData.exactModulePath}::${exactModuleName}`),
18541855
entry,
18551856
path,
1856-
type,
1857+
functionData,
18571858
deprecated: entry ? entry.deprecated : false,
18581859
parent: parentName !== null && parentPath !== null ?
18591860
{ name: parentName, path: parentPath } :
@@ -2563,11 +2564,11 @@ class DocSearch {
25632564
name: item.parent.name,
25642565
ty: item.parent.path.ty,
25652566
} : undefined,
2566-
type: item.type && item.type.functionSignature ?
2567-
item.type.functionSignature :
2567+
type: item.functionData && item.functionData.functionSignature ?
2568+
item.functionData.functionSignature :
25682569
undefined,
2569-
paramNames: item.type && item.type.paramNames ?
2570-
item.type.paramNames :
2570+
paramNames: item.functionData && item.functionData.paramNames ?
2571+
item.functionData.paramNames :
25712572
undefined,
25722573
dist: result.dist,
25732574
path_dist: result.path_dist,
@@ -2642,7 +2643,7 @@ class DocSearch {
26422643
/**
26432644
* @type {rustdoc.Row?}
26442645
*/
2645-
const item = await this.getRow(result.id);
2646+
const item = await this.getRow(result.id, typeInfo !== null);
26462647
if (!item) {
26472648
continue;
26482649
}
@@ -3749,7 +3750,7 @@ class DocSearch {
37493750
is_alias: true,
37503751
elems: [], // only used in type-based queries
37513752
returned: [], // only used in type-based queries
3752-
original: await this.getRow(alias),
3753+
original: await this.getRow(alias, false),
37533754
};
37543755
};
37553756
/**
@@ -3804,7 +3805,7 @@ class DocSearch {
38043805
* @returns {Promise<rustdoc.PlainResultObject?>}
38053806
*/
38063807
const handleNameSearch = async id => {
3807-
const row = await this.getRow(id);
3808+
const row = await this.getRow(id, false);
38083809
if (!row || !row.entry) {
38093810
return null;
38103811
}

0 commit comments

Comments
 (0)