Skip to content

Commit 021a12c

Browse files
committed
Sprinkle some #[inline] in rustc_data_structures::tagged_ptr
1 parent 91b61a4 commit 021a12c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compiler/rustc_data_structures/src/tagged_ptr/copy.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ where
8282
/// drop, use [`TaggedPtr`] instead.
8383
///
8484
/// [`TaggedPtr`]: crate::tagged_ptr::TaggedPtr
85+
#[inline]
8586
pub fn new(pointer: P, tag: T) -> Self {
8687
Self { packed: Self::pack(P::into_ptr(pointer), tag), tag_ghost: PhantomData }
8788
}
8889

8990
/// Retrieves the pointer.
91+
#[inline]
9092
pub fn pointer(self) -> P
9193
where
9294
P: Copy,
@@ -123,6 +125,7 @@ where
123125
/// according to `self.packed` encoding scheme.
124126
///
125127
/// [`P::into_ptr`]: Pointer::into_ptr
128+
#[inline]
126129
fn pack(ptr: NonNull<P::Target>, tag: T) -> NonNull<P::Target> {
127130
// Trigger assert!
128131
let () = Self::ASSERTION;
@@ -145,6 +148,7 @@ where
145148
}
146149

147150
/// Retrieves the original raw pointer from `self.packed`.
151+
#[inline]
148152
pub(super) fn pointer_raw(&self) -> NonNull<P::Target> {
149153
self.packed.map_addr(|addr| unsafe { NonZeroUsize::new_unchecked(addr.get() << T::BITS) })
150154
}
@@ -184,6 +188,7 @@ where
184188
P: Pointer + Copy,
185189
T: Tag,
186190
{
191+
#[inline]
187192
fn clone(&self) -> Self {
188193
*self
189194
}
@@ -196,6 +201,7 @@ where
196201
{
197202
type Target = P::Target;
198203

204+
#[inline]
199205
fn deref(&self) -> &Self::Target {
200206
// Safety:
201207
// `pointer_raw` returns the original pointer from `P::into_ptr` which,
@@ -209,6 +215,7 @@ where
209215
P: Pointer + DerefMut,
210216
T: Tag,
211217
{
218+
#[inline]
212219
fn deref_mut(&mut self) -> &mut Self::Target {
213220
// Safety:
214221
// `pointer_raw` returns the original pointer from `P::into_ptr` which,
@@ -235,6 +242,7 @@ where
235242
P: Pointer,
236243
T: Tag,
237244
{
245+
#[inline]
238246
fn eq(&self, other: &Self) -> bool {
239247
self.packed == other.packed
240248
}
@@ -252,6 +260,7 @@ where
252260
P: Pointer,
253261
T: Tag,
254262
{
263+
#[inline]
255264
fn hash<H: Hasher>(&self, state: &mut H) {
256265
self.packed.hash(state);
257266
}

compiler/rustc_data_structures/src/tagged_ptr/drop.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ where
3030
T: Tag,
3131
{
3232
/// Tags `pointer` with `tag`.
33+
#[inline]
3334
pub fn new(pointer: P, tag: T) -> Self {
3435
TaggedPtr { raw: CopyTaggedPtr::new(pointer, tag) }
3536
}
3637

3738
/// Retrieves the tag.
39+
#[inline]
3840
pub fn tag(&self) -> T {
3941
self.raw.tag()
4042
}
4143

4244
/// Sets the tag to a new value.
45+
#[inline]
4346
pub fn set_tag(&mut self, tag: T) {
4447
self.raw.set_tag(tag)
4548
}
@@ -63,6 +66,8 @@ where
6366
T: Tag,
6467
{
6568
type Target = P::Target;
69+
70+
#[inline]
6671
fn deref(&self) -> &Self::Target {
6772
self.raw.deref()
6873
}
@@ -73,6 +78,7 @@ where
7378
P: Pointer + DerefMut,
7479
T: Tag,
7580
{
81+
#[inline]
7682
fn deref_mut(&mut self) -> &mut Self::Target {
7783
self.raw.deref_mut()
7884
}
@@ -108,6 +114,7 @@ where
108114
P: Pointer,
109115
T: Tag,
110116
{
117+
#[inline]
111118
fn eq(&self, other: &Self) -> bool {
112119
self.raw.eq(&other.raw)
113120
}
@@ -125,6 +132,7 @@ where
125132
P: Pointer,
126133
T: Tag,
127134
{
135+
#[inline]
128136
fn hash<H: Hasher>(&self, state: &mut H) {
129137
self.raw.hash(state);
130138
}

0 commit comments

Comments
 (0)