Skip to content

Commit 47b6bc5

Browse files
committed
Add #[inline] to a bunch of filename related functions
1 parent 9e25221 commit 47b6bc5

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
if !self.was_remapped() {
374380
Some(&self.maybe_remapped.name)
@@ -381,6 +387,7 @@ impl RealFileName {
381387
/// if this information exists.
382388
///
383389
/// May not exists if the filename was imported from another crate.
390+
#[inline]
384391
pub fn into_local_path(self) -> Option<PathBuf> {
385392
if !self.was_remapped() {
386393
Some(self.maybe_remapped.name)
@@ -398,6 +405,7 @@ impl RealFileName {
398405
/// Returns an empty `RealFileName`
399406
///
400407
/// Useful as the working directory input to `SourceMap::to_real_filename`.
408+
#[inline]
401409
pub fn empty() -> RealFileName {
402410
RealFileName {
403411
local: Some(InnerRealFileName {
@@ -543,6 +551,7 @@ impl FileName {
543551
/// if this information exists.
544552
///
545553
/// Avoid embedding this in build artifacts. Prefer using the `display` method.
554+
#[inline]
546555
pub fn prefer_remapped_unconditionally(&self) -> FileNameDisplay<'_> {
547556
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Remapped }
548557
}
@@ -551,16 +560,19 @@ impl FileName {
551560
/// if this information exists.
552561
///
553562
/// Avoid embedding this in build artifacts. Prefer using the `display` method.
563+
#[inline]
554564
pub fn prefer_local_unconditionally(&self) -> FileNameDisplay<'_> {
555565
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Local }
556566
}
557567

558568
/// Returns a short (either the filename or an empty string).
569+
#[inline]
559570
pub fn short(&self) -> FileNameDisplay<'_> {
560571
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Short }
561572
}
562573

563574
/// Returns a `Display`-able path for the given scope.
575+
#[inline]
564576
pub fn display(&self, scope: RemapPathScopeComponents) -> FileNameDisplay<'_> {
565577
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Scope(scope) }
566578
}

0 commit comments

Comments
 (0)