Skip to content

Commit 2ee4f9e

Browse files
committed
Add #[inline] to a bunch of filename related functions
1 parent 07c729e commit 2ee4f9e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/rustc_span/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,14 @@ bitflags::bitflags! {
241241
}
242242

243243
impl<E: Encoder> Encodable<E> for RemapPathScopeComponents {
244+
#[inline]
244245
fn encode(&self, s: &mut E) {
245246
s.emit_u8(self.bits());
246247
}
247248
}
248249

249250
impl<D: Decoder> Decodable<D> for RemapPathScopeComponents {
251+
#[inline]
250252
fn decode(s: &mut D) -> RemapPathScopeComponents {
251253
RemapPathScopeComponents::from_bits(s.read_u8())
252254
.expect("invalid bits for RemapPathScopeComponents")
@@ -308,6 +310,7 @@ struct InnerRealFileName {
308310
}
309311

310312
impl Hash for RealFileName {
313+
#[inline]
311314
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
312315
// To prevent #70924 from happening again we should only hash the
313316
// remapped path if that exists. This is because remapped paths to
@@ -327,6 +330,7 @@ impl RealFileName {
327330
/// ## Panic
328331
///
329332
/// Only one scope components can be given to this function.
333+
#[inline]
330334
pub fn path(&self, scope: RemapPathScopeComponents) -> &Path {
331335
assert!(
332336
scope.bits().count_ones() == 1,
@@ -351,6 +355,7 @@ impl RealFileName {
351355
/// ## Panic
352356
///
353357
/// Only one scope components can be given to this function.
358+
#[inline]
354359
pub fn embeddable_name(&self, scope: RemapPathScopeComponents) -> (&Path, &Path) {
355360
assert!(
356361
scope.bits().count_ones() == 1,
@@ -369,6 +374,7 @@ impl RealFileName {
369374
/// if this information exists.
370375
///
371376
/// May not exists if the filename was imported from another crate.
377+
#[inline]
372378
pub fn local_path(&self) -> Option<&Path> {
373379
self.local.as_ref().map(|lp| lp.name.as_ref())
374380
}
@@ -377,6 +383,7 @@ impl RealFileName {
377383
/// if this information exists.
378384
///
379385
/// May not exists if the filename was imported from another crate.
386+
#[inline]
380387
pub fn into_local_path(self) -> Option<PathBuf> {
381388
self.local.map(|lp| lp.name)
382389
}
@@ -390,6 +397,7 @@ impl RealFileName {
390397
/// Returns an empty `RealFileName`
391398
///
392399
/// Useful as the working directory input to `SourceMap::to_real_filename`.
400+
#[inline]
393401
pub fn empty() -> RealFileName {
394402
RealFileName {
395403
local: Some(InnerRealFileName {
@@ -535,6 +543,7 @@ impl FileName {
535543
/// if this information exists.
536544
///
537545
/// Avoid embedding this in build artifacts. Prefer using the `display` method.
546+
#[inline]
538547
pub fn prefer_remapped_unconditionally(&self) -> FileNameDisplay<'_> {
539548
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Remapped }
540549
}
@@ -543,16 +552,19 @@ impl FileName {
543552
/// if this information exists.
544553
///
545554
/// Avoid embedding this in build artifacts. Prefer using the `display` method.
555+
#[inline]
546556
pub fn prefer_local_unconditionally(&self) -> FileNameDisplay<'_> {
547557
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Local }
548558
}
549559

550560
/// Returns a short (either the filename or an empty string).
561+
#[inline]
551562
pub fn short(&self) -> FileNameDisplay<'_> {
552563
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Short }
553564
}
554565

555566
/// Returns a `Display`-able path for the given scope.
567+
#[inline]
556568
pub fn display(&self, scope: RemapPathScopeComponents) -> FileNameDisplay<'_> {
557569
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Scope(scope) }
558570
}

0 commit comments

Comments
 (0)