1
Fork 0

rustdoc: Use an array instead of an object for the search index.

`buildIndex` JS function recovers them into the original object form.
This greatly reduces the size of the uncompressed search index (27%),
while this effect is less visible after gzipped (~5%).
This commit is contained in:
Kang Seonghoon 2014-04-09 17:16:09 +09:00
parent f1de04c760
commit f6854ab46c
2 changed files with 16 additions and 12 deletions

View file

@ -313,17 +313,17 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
if i > 0 {
try!(write!(&mut w, ","));
}
try!(write!(&mut w, "\\{ty:{:u},name:\"{}\",path:\"{}\",desc:{}",
try!(write!(&mut w, r#"[{:u},"{}","{}",{}"#,
item.ty, item.name, item.path,
item.desc.to_json().to_str()));
match item.parent {
Some(nodeid) => {
let pathid = *nodeid_to_pathid.find(&nodeid).unwrap();
try!(write!(&mut w, ",parent:{}", pathid));
try!(write!(&mut w, ",{}", pathid));
}
None => {}
}
try!(write!(&mut w, "\\}"));
try!(write!(&mut w, "]"));
}
try!(write!(&mut w, "];"));
try!(write!(&mut w, "allPaths['{}'] = [", krate.name));
@ -332,7 +332,7 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
if i > 0 {
try!(write!(&mut w, ","));
}
try!(write!(&mut w, "\\{type:{:u},name:'{}'\\}",
try!(write!(&mut w, r#"[{:u},"{}"]"#,
short, *fqp.last().unwrap()));
}
try!(write!(&mut w, "];"));