@@ -167,23 +167,24 @@ pub(super) fn write_shared(
167
167
let mut krates = Vec :: new ( ) ;
168
168
169
169
if path. exists ( ) {
170
- let prefix = format ! ( "\" {krate}\" " ) ;
170
+ let prefix = format ! ( "[ \" {krate}\" " ) ;
171
171
for line in BufReader :: new ( File :: open ( path) ?) . lines ( ) {
172
172
let line = line?;
173
- if !line. starts_with ( '"' ) {
173
+ if !line. starts_with ( "[ \" " ) {
174
174
continue ;
175
175
}
176
176
if line. starts_with ( & prefix) {
177
177
continue ;
178
178
}
179
- if line. ends_with ( ",\\ " ) {
179
+ if line. ends_with ( "] ,\\ " ) {
180
180
ret. push ( line[ ..line. len ( ) - 2 ] . to_string ( ) ) ;
181
181
} else {
182
182
// Ends with "\\" (it's the case for the last added crate line)
183
183
ret. push ( line[ ..line. len ( ) - 1 ] . to_string ( ) ) ;
184
184
}
185
185
krates. push (
186
- line. split ( '"' )
186
+ line[ 1 ..] // We skip the `[` parent at the beginning of the line.
187
+ . split ( '"' )
187
188
. find ( |s| !s. is_empty ( ) )
188
189
. map ( |s| s. to_owned ( ) )
189
190
. unwrap_or_else ( String :: new) ,
@@ -285,7 +286,7 @@ pub(super) fn write_shared(
285
286
let ( mut all_sources, _krates) =
286
287
try_err ! ( collect_json( & dst, krate. name( cx. tcx( ) ) . as_str( ) ) , & dst) ;
287
288
all_sources. push ( format ! (
288
- r#""{}":{} "# ,
289
+ r#"[ "{}",{}] "# ,
289
290
& krate. name( cx. tcx( ) ) ,
290
291
hierarchy
291
292
. to_json_string( )
@@ -296,9 +297,9 @@ pub(super) fn write_shared(
296
297
. replace( "\\ \" " , "\\ \\ \" " )
297
298
) ) ;
298
299
all_sources. sort ( ) ;
299
- let mut v = String :: from ( "var srcIndex = JSON.parse('{ \\ \n " ) ;
300
+ let mut v = String :: from ( "const srcIndex = new Map( JSON.parse('[ \\ \n " ) ;
300
301
v. push_str ( & all_sources. join ( ",\\ \n " ) ) ;
301
- v. push_str ( "\\ \n }' );\n createSrcSidebar();\n " ) ;
302
+ v. push_str ( "\\ \n ]') );\n createSrcSidebar();\n " ) ;
302
303
Ok ( v. into_bytes ( ) )
303
304
} ;
304
305
write_invocation_specific ( "src-files.js" , & make_sources) ?;
@@ -316,11 +317,11 @@ pub(super) fn write_shared(
316
317
// with rustdoc running in parallel.
317
318
all_indexes. sort ( ) ;
318
319
write_invocation_specific ( "search-index.js" , & || {
319
- let mut v = String :: from ( "var searchIndex = JSON.parse('{ \\ \n " ) ;
320
+ let mut v = String :: from ( "const searchIndex = new Map( JSON.parse('[ \\ \n " ) ;
320
321
v. push_str ( & all_indexes. join ( ",\\ \n " ) ) ;
321
322
v. push_str (
322
323
r#"\
323
- }' );
324
+ ]') );
324
325
if (typeof window !== 'undefined' && window.initSearch) {window.initSearch(searchIndex)};
325
326
if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
326
327
"# ,
0 commit comments