From c79af862401465a7241e6920ba31f34adafa44fd Mon Sep 17 00:00:00 2001 From: Camelid Date: Wed, 3 Mar 2021 20:04:27 -0800 Subject: [PATCH] Pass `CrateNum` by value instead of by reference It's more idiomatic to pass a small Copy type by value and `CrateNum` is half the size of `&CrateNum` on 64-bit systems. The memory use change is almost certainly insignificant, but why not! --- src/librustdoc/clean/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 09ba0e2740f1b..e3f47a85d5154 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -191,7 +191,7 @@ impl Item { } crate fn links(&self, cache: &Cache) -> Vec { - self.attrs.links(&self.def_id.krate, cache) + self.attrs.links(self.def_id.krate, cache) } crate fn is_crate(&self) -> bool { @@ -844,7 +844,7 @@ impl Attributes { /// Gets links as a vector /// /// Cache must be populated before call - crate fn links(&self, krate: &CrateNum, cache: &Cache) -> Vec { + crate fn links(&self, krate: CrateNum, cache: &Cache) -> Vec { use crate::html::format::href; use crate::html::render::CURRENT_DEPTH; @@ -869,7 +869,7 @@ impl Attributes { } None => { if let Some(ref fragment) = *fragment { - let url = match cache.extern_locations.get(krate) { + let url = match cache.extern_locations.get(&krate) { Some(&(_, _, ExternalLocation::Local)) => { let depth = CURRENT_DEPTH.with(|l| l.get()); "../".repeat(depth)