Skip to content

Commit

Permalink
Rollup merge of #82744 - camelid:cratenum-byval, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
JohnTitor authored Mar 4, 2021
2 parents 17121f2 + c79af86 commit 06630f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
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 06630f7

Please sign in to comment.