@@ -1825,6 +1825,24 @@ function initSearch(rawSearchIndex) {
1825
1825
filterCrates ) ;
1826
1826
}
1827
1827
1828
+ /**
1829
+ * Convert a list of RawFunctionType / ID to object-based FunctionType.
1830
+ *
1831
+ * Crates often have lots of functions in them, and it's common to have a large number of
1832
+ * functions that operate on a small set of data types, so the search index compresses them
1833
+ * by encoding function parameter and return types as indexes into an array of names.
1834
+ *
1835
+ * Even when a general-purpose compression algorithm is used, this is still a win. I checked.
1836
+ * https://github.com/rust-lang/rust/pull/98475#issue-1284395985
1837
+ *
1838
+ * The format for individual function types is encoded in
1839
+ * librustdoc/html/render/mod.rs: impl Serialize for RenderType
1840
+ *
1841
+ * @param {null|Array<RawFunctionType> } types
1842
+ * @param {Array<{name: string, ty: number}> } lowercasePaths
1843
+ *
1844
+ * @return {Array<FunctionSearchType> }
1845
+ */
1828
1846
function buildItemSearchTypeAll ( types , lowercasePaths ) {
1829
1847
const PATH_INDEX_DATA = 0 ;
1830
1848
const GENERICS_DATA = 1 ;
@@ -1848,6 +1866,21 @@ function initSearch(rawSearchIndex) {
1848
1866
} ) ;
1849
1867
}
1850
1868
1869
+ /**
1870
+ * Convert from RawFunctionSearchType to FunctionSearchType.
1871
+ *
1872
+ * Crates often have lots of functions in them, and function signatures are sometimes complex,
1873
+ * so rustdoc uses a pretty tight encoding for them. This function converts it to a simpler,
1874
+ * object-based encoding so that the actual search code is more readable and easier to debug.
1875
+ *
1876
+ * The raw function search type format is generated using serde in
1877
+ * librustdoc/html/render/mod.rs: impl Serialize for IndexItemFunctionType
1878
+ *
1879
+ * @param {RawFunctionSearchType } functionSearchType
1880
+ * @param {Array<{name: string, ty: number}> } lowercasePaths
1881
+ *
1882
+ * @return {null|FunctionSearchType }
1883
+ */
1851
1884
function buildFunctionSearchType ( functionSearchType , lowercasePaths ) {
1852
1885
const INPUTS_DATA = 0 ;
1853
1886
const OUTPUT_DATA = 1 ;
@@ -1935,7 +1968,7 @@ function initSearch(rawSearchIndex) {
1935
1968
* d: Array<string>,
1936
1969
* q: Array<string>,
1937
1970
* i: Array<Number>,
1938
- * f: Array<0 | Object >,
1971
+ * f: Array<RawFunctionSearchType >,
1939
1972
* p: Array<Object>,
1940
1973
* }}
1941
1974
*/
0 commit comments