1
Fork 0

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!
This commit is contained in:
Camelid 2021-03-03 20:04:27 -08:00
parent 939b14334d
commit c79af86240

View file

@ -191,7 +191,7 @@ impl Item {
} }
crate fn links(&self, cache: &Cache) -> Vec<RenderedLink> { crate fn links(&self, cache: &Cache) -> Vec<RenderedLink> {
self.attrs.links(&self.def_id.krate, cache) self.attrs.links(self.def_id.krate, cache)
} }
crate fn is_crate(&self) -> bool { crate fn is_crate(&self) -> bool {
@ -844,7 +844,7 @@ impl Attributes {
/// Gets links as a vector /// Gets links as a vector
/// ///
/// Cache must be populated before call /// Cache must be populated before call
crate fn links(&self, krate: &CrateNum, cache: &Cache) -> Vec<RenderedLink> { crate fn links(&self, krate: CrateNum, cache: &Cache) -> Vec<RenderedLink> {
use crate::html::format::href; use crate::html::format::href;
use crate::html::render::CURRENT_DEPTH; use crate::html::render::CURRENT_DEPTH;
@ -869,7 +869,7 @@ impl Attributes {
} }
None => { None => {
if let Some(ref fragment) = *fragment { 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)) => { Some(&(_, _, ExternalLocation::Local)) => {
let depth = CURRENT_DEPTH.with(|l| l.get()); let depth = CURRENT_DEPTH.with(|l| l.get());
"../".repeat(depth) "../".repeat(depth)