Skip to content

Commit c877536

Browse files
committed
Add #[inline] to a bunch of filename related functions
1 parent 7227bfe commit c877536

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

compiler/rustc_span/src/lib.rs

Lines changed: 13 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_not_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_not_remapped() {
386393
Some(self.maybe_remapped.name)
@@ -390,6 +397,7 @@ impl RealFileName {
390397
}
391398

392399
/// Returns whenever the filename was remapped.
400+
#[inline]
393401
pub(crate) fn was_remapped(&self) -> bool {
394402
!self.scopes.is_empty()
395403
}
@@ -409,6 +417,7 @@ impl RealFileName {
409417
/// Returns an empty `RealFileName`
410418
///
411419
/// Useful as the working directory input to `SourceMap::to_real_filename`.
420+
#[inline]
412421
pub fn empty() -> RealFileName {
413422
RealFileName {
414423
local: Some(InnerRealFileName {
@@ -554,6 +563,7 @@ impl FileName {
554563
/// if this information exists.
555564
///
556565
/// Avoid embedding this in build artifacts. Prefer using the `display` method.
566+
#[inline]
557567
pub fn prefer_remapped_unconditionally(&self) -> FileNameDisplay<'_> {
558568
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Remapped }
559569
}
@@ -562,16 +572,19 @@ impl FileName {
562572
/// if this information exists.
563573
///
564574
/// Avoid embedding this in build artifacts. Prefer using the `display` method.
575+
#[inline]
565576
pub fn prefer_local_unconditionally(&self) -> FileNameDisplay<'_> {
566577
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Local }
567578
}
568579

569580
/// Returns a short (either the filename or an empty string).
581+
#[inline]
570582
pub fn short(&self) -> FileNameDisplay<'_> {
571583
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Short }
572584
}
573585

574586
/// Returns a `Display`-able path for the given scope.
587+
#[inline]
575588
pub fn display(&self, scope: RemapPathScopeComponents) -> FileNameDisplay<'_> {
576589
FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Scope(scope) }
577590
}

0 commit comments

Comments
 (0)