mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibJS: Avoid unnecessary shifts in Value empty/null/undefined checks
We know that the payload is always 0 for these three Value types, and so we can implement checking for them as full 64-bit compares against constant values instead of checking just the tag. This avoids shifting the tag 48 bits to the right before comparing it. Since these are used all over the place, it actually leads to a nice code size reduction.
This commit is contained in:
parent
c8865458da
commit
d138474e0d
|
|
@ -95,9 +95,9 @@ public:
|
|||
|
||||
[[nodiscard]] u16 tag() const { return m_value.tag; }
|
||||
|
||||
bool is_special_empty_value() const { return m_value.tag == EMPTY_TAG; }
|
||||
bool is_undefined() const { return m_value.tag == UNDEFINED_TAG; }
|
||||
bool is_null() const { return m_value.tag == NULL_TAG; }
|
||||
bool is_special_empty_value() const { return m_value.encoded == (EMPTY_TAG << GC::TAG_SHIFT); }
|
||||
bool is_undefined() const { return m_value.encoded == (UNDEFINED_TAG << GC::TAG_SHIFT); }
|
||||
bool is_null() const { return m_value.encoded == (NULL_TAG << GC::TAG_SHIFT); }
|
||||
bool is_number() const { return is_double() || is_int32(); }
|
||||
bool is_string() const { return m_value.tag == STRING_TAG; }
|
||||
bool is_object() const { return m_value.tag == OBJECT_TAG; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user