Skip to content

Commit

Permalink
Merge pull request #1240 from Shopify/fix/optimise-isset
Browse files Browse the repository at this point in the history
Optimised isUndefinedOrNull() check for DOM properties
  • Loading branch information
chrfalch authored Jan 6, 2023
2 parents c648c34 + fc340b7 commit 36c3748
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions package/cpp/jsi/JsiValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ namespace RNJsi {
namespace jsi = facebook::jsi;

enum struct PropType {
Undefined = 1,
Null = 2,
Bool = 4,
Number = 8,
String = 16,
Object = 32,
HostObject = 64,
HostFunction = 128,
Array = 256
Undefined = 0,
Null = 1, // Keep undefined / null constant so that we can do checks faster
Bool = 2,
Number = 3,
String = 4,
Object = 5,
HostObject = 6,
HostFunction = 7,
Array = 8
};

using PropId = const char *;
Expand Down Expand Up @@ -80,7 +80,7 @@ class JsiValue {
/**
Returns true if the value is undefined or null.
*/
bool isUndefinedOrNull() const { return isUndefined() || isNull(); }
bool isUndefinedOrNull() const { return _type <= PropType::Null; }

/**
Returns true if the value is undefined.
Expand Down

0 comments on commit 36c3748

Please sign in to comment.