mirror of
https://github.com/rust-lang/rust.git
synced 2026-03-23 15:45:23 +00:00
Move code inside the else in TypeAliasPart::get.
This is a huge perf win for rustdoc on the `typenum` and `nalgebra` benchmarks, because the `else` branch doesn't get hit much.
This commit is contained in:
@@ -623,35 +623,6 @@ impl TypeAliasPart {
|
||||
for &(type_alias_fqp, type_alias_item) in type_aliases {
|
||||
cx.id_map.borrow_mut().clear();
|
||||
cx.deref_id_map.borrow_mut().clear();
|
||||
let target_did = impl_
|
||||
.inner_impl()
|
||||
.trait_
|
||||
.as_ref()
|
||||
.map(|trait_| trait_.def_id())
|
||||
.or_else(|| impl_.inner_impl().for_.def_id(&cx.shared.cache));
|
||||
let provided_methods;
|
||||
let assoc_link = if let Some(target_did) = target_did {
|
||||
provided_methods = impl_.inner_impl().provided_trait_methods(cx.tcx());
|
||||
AssocItemLink::GotoSource(ItemId::DefId(target_did), &provided_methods)
|
||||
} else {
|
||||
AssocItemLink::Anchor(None)
|
||||
};
|
||||
let text = super::render_impl(
|
||||
cx,
|
||||
impl_,
|
||||
type_alias_item,
|
||||
assoc_link,
|
||||
RenderMode::Normal,
|
||||
None,
|
||||
&[],
|
||||
ImplRenderingParameters {
|
||||
show_def_docs: true,
|
||||
show_default_items: true,
|
||||
show_non_assoc_items: true,
|
||||
toggle_open_by_default: true,
|
||||
},
|
||||
)
|
||||
.to_string();
|
||||
let type_alias_fqp = (*type_alias_fqp).iter().join("::");
|
||||
if ret.last().map(|s: &AliasSerializableImpl| &s.text).is_some() {
|
||||
ret.last_mut()
|
||||
@@ -659,6 +630,39 @@ impl TypeAliasPart {
|
||||
.aliases
|
||||
.push(type_alias_fqp);
|
||||
} else {
|
||||
let target_did = impl_
|
||||
.inner_impl()
|
||||
.trait_
|
||||
.as_ref()
|
||||
.map(|trait_| trait_.def_id())
|
||||
.or_else(|| impl_.inner_impl().for_.def_id(&cx.shared.cache));
|
||||
let provided_methods;
|
||||
let assoc_link = if let Some(target_did) = target_did {
|
||||
provided_methods =
|
||||
impl_.inner_impl().provided_trait_methods(cx.tcx());
|
||||
AssocItemLink::GotoSource(
|
||||
ItemId::DefId(target_did),
|
||||
&provided_methods,
|
||||
)
|
||||
} else {
|
||||
AssocItemLink::Anchor(None)
|
||||
};
|
||||
let text = super::render_impl(
|
||||
cx,
|
||||
impl_,
|
||||
type_alias_item,
|
||||
assoc_link,
|
||||
RenderMode::Normal,
|
||||
None,
|
||||
&[],
|
||||
ImplRenderingParameters {
|
||||
show_def_docs: true,
|
||||
show_default_items: true,
|
||||
show_non_assoc_items: true,
|
||||
toggle_open_by_default: true,
|
||||
},
|
||||
)
|
||||
.to_string();
|
||||
ret.push(AliasSerializableImpl {
|
||||
text,
|
||||
trait_: trait_.clone(),
|
||||
|
||||
Reference in New Issue
Block a user