Auto merge of #120579 - GuillaumeGomez:prevent-running-unneeded-code, r=notriddle

Prevent running some code if it is already in the map

I realized that a lot of duplicates were being run through this function. Might be better to prevent them from computing all the information if it's already in the cache.

r? `@notriddle`
This commit is contained in:
bors 2024-02-08 07:55:03 +00:00
commit 81bef0b0ba

View File

@ -196,6 +196,14 @@ pub(crate) fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> &'hir [ast:
/// These names are used later on by HTML rendering to generate things like
/// source links back to the original item.
pub(crate) fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType) {
if did.is_local() {
if cx.cache.exact_paths.contains_key(&did) {
return;
}
} else if cx.cache.external_paths.contains_key(&did) {
return;
}
let crate_name = cx.tcx.crate_name(did.krate);
let relative =