Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/intern/src/symbol.rs')
| -rw-r--r-- | crates/intern/src/symbol.rs | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/crates/intern/src/symbol.rs b/crates/intern/src/symbol.rs index 8b2d6e8717..72d32d1017 100644 --- a/crates/intern/src/symbol.rs +++ b/crates/intern/src/symbol.rs @@ -73,10 +73,9 @@ impl TaggedArcPtr { /// /// You can only drop the `Arc` if the instance is dropped. #[inline] - pub(crate) unsafe fn try_as_arc_owned(self) -> Option<ManuallyDrop<Arc<Box<str>>>> { + unsafe fn try_as_arc_owned(self) -> Option<ManuallyDrop<Arc<Box<str>>>> { // Unpack the tag from the alignment niche - let tag = self.packed.as_ptr().addr() & Self::BOOL_BITS; - if tag != 0 { + if self.is_arc() { // Safety: We checked that the tag is non-zero -> true, so we are pointing to the data offset of an `Arc` Some(ManuallyDrop::new(unsafe { Arc::from_raw(self.pointer().as_ptr().cast::<Box<str>>()) @@ -87,6 +86,11 @@ impl TaggedArcPtr { } #[inline] + fn is_arc(&self) -> bool { + (self.packed.as_ptr().addr() & Self::BOOL_BITS) != 0 + } + + #[inline] fn pack_arc(ptr: NonNull<*const str>) -> NonNull<*const str> { let packed_tag = true as usize; @@ -161,28 +165,6 @@ impl Symbol { unsafe { bucket.as_ref().0.clone() } } - pub fn integer(i: usize) -> Self { - match i { - 0 => symbols::INTEGER_0, - 1 => symbols::INTEGER_1, - 2 => symbols::INTEGER_2, - 3 => symbols::INTEGER_3, - 4 => symbols::INTEGER_4, - 5 => symbols::INTEGER_5, - 6 => symbols::INTEGER_6, - 7 => symbols::INTEGER_7, - 8 => symbols::INTEGER_8, - 9 => symbols::INTEGER_9, - 10 => symbols::INTEGER_10, - 11 => symbols::INTEGER_11, - 12 => symbols::INTEGER_12, - 13 => symbols::INTEGER_13, - 14 => symbols::INTEGER_14, - 15 => symbols::INTEGER_15, - i => Symbol::intern(&format!("{i}")), - } - } - pub fn empty() -> Self { symbols::__empty } |