rustdoc: Small micro-optimizations and cleanups
* Flip conjuncts of `&&` in rustdoc The `CrateNum` comparison should be very cheap, while `span.filename()` fetches and clones a `FileName`. * Use `into_local_path()` instead of `local_path().clone()`
This commit is contained in:
parent
4ee2d0351a
commit
10606c3caf
1 changed files with 8 additions and 7 deletions
|
|
@ -44,7 +44,7 @@ struct LocalSourcesCollector<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn is_real_and_local(span: clean::Span, sess: &Session) -> bool {
|
||||
span.filename(sess).is_real() && span.cnum(sess) == LOCAL_CRATE
|
||||
span.cnum(sess) == LOCAL_CRATE && span.filename(sess).is_real()
|
||||
}
|
||||
|
||||
impl LocalSourcesCollector<'_, '_> {
|
||||
|
|
@ -56,12 +56,13 @@ impl LocalSourcesCollector<'_, '_> {
|
|||
return;
|
||||
}
|
||||
let filename = span.filename(sess);
|
||||
let p = match filename {
|
||||
FileName::Real(ref file) => match file.local_path() {
|
||||
Some(p) => p.to_path_buf(),
|
||||
_ => return,
|
||||
},
|
||||
_ => return,
|
||||
let p = if let FileName::Real(file) = filename {
|
||||
match file.into_local_path() {
|
||||
Some(p) => p,
|
||||
None => return,
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
if self.local_sources.contains_key(&*p) {
|
||||
// We've already emitted this source
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue