Skip to content

Commit

Permalink
Factor Tag::is_object to let Val::is_object delegate to it (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Sep 18, 2023
1 parent 1dccd1c commit b6bcee4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions soroban-env-common/src/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,24 @@ pub enum Tag {
}

impl Tag {
#[inline(always)]
pub const fn rawval_mask() -> i64 {
TAG_MASK as i64
}

#[inline(always)]
pub fn rawval_const(&self) -> i64 {
*self as i64
}

#[inline(always)]
pub(crate) const fn u8_is_object(x: u8) -> bool {
x > (Tag::ObjectCodeLowerBound as u8) && x < (Tag::ObjectCodeUpperBound as u8)
}

#[inline(always)]
pub const fn is_object(self) -> bool {
let tu8 = self as u8;
tu8 > (Tag::ObjectCodeLowerBound as u8) && tu8 < (Tag::ObjectCodeUpperBound as u8)
Self::u8_is_object(self as u8)
}

#[inline(always)]
Expand Down Expand Up @@ -638,8 +647,7 @@ impl Val {

#[inline(always)]
pub const fn is_object(self) -> bool {
let tag = self.get_tag_u8();
tag > (Tag::ObjectCodeLowerBound as u8) && tag < (Tag::ObjectCodeUpperBound as u8)
Tag::u8_is_object(self.get_tag_u8())
}

#[inline(always)]
Expand Down

0 comments on commit b6bcee4

Please sign in to comment.