Skip to content

Commit 00c399e

Browse files
committed
rustc_span: Inline new hot functions
1 parent 8c62dc1 commit 00c399e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/rustc_span/src/span_encoding.rs

+12
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ enum Fmt<'a> {
124124
}
125125

126126
impl InlineCtxt {
127+
#[inline]
127128
fn data(self) -> SpanData {
128129
let len = self.len as u32;
129130
debug_assert!(len <= MAX_LEN);
@@ -134,12 +135,14 @@ impl InlineCtxt {
134135
parent: None,
135136
}
136137
}
138+
#[inline]
137139
fn to_span(self) -> Span {
138140
unsafe { transmute(self) }
139141
}
140142
}
141143

142144
impl InlineParent {
145+
#[inline]
143146
fn data(self) -> SpanData {
144147
let len = (self.len_with_tag & !PARENT_TAG) as u32;
145148
debug_assert!(len <= MAX_LEN);
@@ -150,33 +153,39 @@ impl InlineParent {
150153
parent: Some(LocalDefId { local_def_index: DefIndex::from_u32(self.parent as u32) }),
151154
}
152155
}
156+
#[inline]
153157
fn to_span(self) -> Span {
154158
unsafe { transmute(self) }
155159
}
156160
}
157161

158162
impl PartiallyInterned {
163+
#[inline]
159164
fn data(self) -> SpanData {
160165
SpanData {
161166
ctxt: SyntaxContext::from_u32(self.ctxt as u32),
162167
..with_span_interner(|interner| interner.spans[self.index as usize])
163168
}
164169
}
170+
#[inline]
165171
fn to_span(self) -> Span {
166172
unsafe { transmute(self) }
167173
}
168174
}
169175

170176
impl Interned {
177+
#[inline]
171178
fn data(self) -> SpanData {
172179
with_span_interner(|interner| interner.spans[self.index as usize])
173180
}
181+
#[inline]
174182
fn to_span(self) -> Span {
175183
unsafe { transmute(self) }
176184
}
177185
}
178186

179187
impl Fmt<'_> {
188+
#[inline]
180189
fn data(self) -> SpanData {
181190
match self {
182191
Fmt::InlineCtxt(span) => span.data(),
@@ -241,6 +250,7 @@ impl Span {
241250
}
242251
}
243252

253+
#[inline]
244254
fn fmt(&mut self) -> Fmt<'_> {
245255
if self.len_with_tag_or_marker != BASE_LEN_INTERNED_MARKER {
246256
if self.len_with_tag_or_marker & PARENT_TAG == 0 {
@@ -291,6 +301,7 @@ impl Span {
291301
// For optimization we are interested in cases in which the context is inline and the context
292302
// update doesn't change format. All non-inline or format changing scenarios require accessing
293303
// interner and can fall back to `Span::new`.
304+
#[inline]
294305
pub fn update_ctxt(&mut self, update: impl FnOnce(SyntaxContext) -> SyntaxContext) {
295306
// FIXME(#125017): Update ctxt inline without touching interner when possible.
296307
let data = self.data();
@@ -299,6 +310,7 @@ impl Span {
299310

300311
// Returns either syntactic context, if it can be retrieved without taking the interner lock,
301312
// or an index into the interner if it cannot.
313+
#[inline]
302314
fn inline_ctxt(mut self) -> Result<SyntaxContext, usize> {
303315
match self.fmt() {
304316
Fmt::InlineCtxt(InlineCtxt { ctxt, .. })

0 commit comments

Comments
 (0)