rustdoc: Make it easy to switch between parallel and sequential folds
This commit is contained in:
parent
1ee139ae1f
commit
8b071ebe4c
@ -27,7 +27,7 @@ fn run(
|
||||
fold_res: fold_res,
|
||||
fold_iface: fold_iface,
|
||||
fold_impl: fold_impl
|
||||
with *fold::default_par_fold(srv)
|
||||
with *fold::default_any_fold(srv)
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ fn run(
|
||||
fold_res: fold_res,
|
||||
fold_iface: fold_iface,
|
||||
fold_impl: fold_impl
|
||||
with *fold::default_par_fold(op)
|
||||
with *fold::default_any_fold(op)
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ fn run(
|
||||
fold_item: fold_item,
|
||||
fold_iface: fold_iface,
|
||||
fold_impl: fold_impl
|
||||
with *fold::default_par_fold(())
|
||||
with *fold::default_any_fold(())
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ export default_seq_fold_impl;
|
||||
export default_seq_fold_type;
|
||||
export default_par_fold;
|
||||
export default_par_fold_mod;
|
||||
export default_any_fold;
|
||||
export default_any_fold_mod;
|
||||
|
||||
enum fold<T> = t<T>;
|
||||
|
||||
@ -104,6 +106,12 @@ fn default_par_fold<T:send>(ctxt: T) -> fold<T> {
|
||||
)
|
||||
}
|
||||
|
||||
// Just a convenient wrapper to convert back and forth between
|
||||
// parallel and sequential folds for perf testing
|
||||
fn default_any_fold<T:send>(ctxt: T) -> fold<T> {
|
||||
default_par_fold(ctxt)
|
||||
}
|
||||
|
||||
fn default_seq_fold_crate<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::cratedoc
|
||||
@ -146,6 +154,13 @@ fn default_par_fold_mod<T:send>(
|
||||
}
|
||||
}
|
||||
|
||||
fn default_any_fold_mod<T:send>(
|
||||
fold: fold<T>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
default_par_fold_mod(fold, doc)
|
||||
}
|
||||
|
||||
fn fold_itemtag<T>(fold: fold<T>, doc: doc::itemtag) -> doc::itemtag {
|
||||
alt doc {
|
||||
doc::modtag(moddoc) {
|
||||
|
@ -17,7 +17,7 @@ fn run(srv: astsrv::srv, doc: doc::cratedoc) -> doc::cratedoc {
|
||||
let fold = fold::fold({
|
||||
fold_item: fold_item,
|
||||
fold_mod: fold_mod
|
||||
with *fold::default_par_fold(ctxt)
|
||||
with *fold::default_any_fold(ctxt)
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
@ -33,7 +33,7 @@ fn fold_mod(fold: fold::fold<ctxt>, doc: doc::moddoc) -> doc::moddoc {
|
||||
let is_topmod = doc.id() == rustc::syntax::ast::crate_node_id;
|
||||
|
||||
if !is_topmod { vec::push(fold.ctxt.path, doc.name()); }
|
||||
let doc = fold::default_par_fold_mod(fold, doc);
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
if !is_topmod { vec::pop(fold.ctxt.path); }
|
||||
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ fn run(
|
||||
fold_res: fold_res,
|
||||
fold_iface: fold_iface,
|
||||
fold_impl: fold_impl
|
||||
with *fold::default_par_fold(())
|
||||
with *fold::default_any_fold(())
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ fn run(
|
||||
fold_iface: fold_iface,
|
||||
fold_impl: fold_impl,
|
||||
fold_type: fold_type
|
||||
with *fold::default_par_fold(ctxt)
|
||||
with *fold::default_any_fold(ctxt)
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
@ -105,7 +105,7 @@ fn fold_mod(
|
||||
_ { some(itemtag) }
|
||||
}
|
||||
}
|
||||
with fold::default_par_fold_mod(fold, doc)
|
||||
with fold::default_any_fold_mod(fold, doc)
|
||||
};
|
||||
fold.ctxt.have_docs =
|
||||
doc.brief() != none
|
||||
|
@ -13,13 +13,13 @@ fn mk_pass() -> pass {
|
||||
fn run(srv: astsrv::srv, doc: doc::cratedoc) -> doc::cratedoc {
|
||||
let fold = fold::fold({
|
||||
fold_mod: fold_mod
|
||||
with *fold::default_par_fold(srv)
|
||||
with *fold::default_any_fold(srv)
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
|
||||
fn fold_mod(fold: fold::fold<astsrv::srv>, doc: doc::moddoc) -> doc::moddoc {
|
||||
let doc = fold::default_par_fold_mod(fold, doc);
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
{
|
||||
items: ~exported_items(fold.ctxt, doc)
|
||||
with doc
|
||||
|
@ -19,7 +19,7 @@ fn run(
|
||||
) -> doc::cratedoc {
|
||||
let fold = fold::fold({
|
||||
fold_mod: fold_mod
|
||||
with *fold::default_par_fold(lteq)
|
||||
with *fold::default_any_fold(lteq)
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
@ -28,7 +28,7 @@ fn fold_mod(
|
||||
fold: fold::fold<item_lteq>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
let doc = fold::default_par_fold_mod(fold, doc);
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
{
|
||||
items: ~sort::merge_sort(fold.ctxt, *doc.items)
|
||||
with doc
|
||||
|
@ -23,7 +23,7 @@ fn run(
|
||||
fold_iface: fold_iface,
|
||||
fold_impl: fold_impl,
|
||||
fold_type: fold_type
|
||||
with *fold::default_par_fold(srv)
|
||||
with *fold::default_any_fold(srv)
|
||||
});
|
||||
fold.fold_crate(fold, doc)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user