Skip to content

Commit

Permalink
Pass CrateNum by value instead of by reference
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
camelid committed Mar 4, 2021
1 parent 939b143 commit c79af86
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/librustdoc/clean/types.rs
Expand Up @@ -191,7 +191,7 @@ impl Item {
}

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 {
Expand Down Expand Up @@ -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<RenderedLink> {
crate fn links(&self, krate: CrateNum, cache: &Cache) -> Vec<RenderedLink> {
use crate::html::format::href;
use crate::html::render::CURRENT_DEPTH;

Expand All @@ -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)
Expand Down

0 comments on commit c79af86

Please sign in to comment.