Skip to content

Commit

Permalink
Statically cache the String value of g_internal_field for a small per…
Browse files Browse the repository at this point in the history
…formance gain
  • Loading branch information
Tom Duncalf committed Sep 5, 2022
1 parent a3747c1 commit b80c02f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/jsi/jsi_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ class ObjectWrap {

static Internal* get_internal(JsiEnv env, const JsiObj& object)
{
auto internal = object->getProperty(env, g_internal_field);
static const auto js_internal_field = fbjsi::String::createFromAscii(env, g_internal_field);

auto internal = object->getProperty(env, js_internal_field);
if (internal.isUndefined()) {
// In the case of a user opening a Realm with a class-based model,
// the user defined constructor will get called before the "internal" property has been set.
Expand Down Expand Up @@ -663,7 +665,8 @@ class ObjectWrap {
} // namespace realmjsi

template <typename ClassType>
class ObjectWrap<realmjsi::Types, ClassType> : public realm::js::realmjsi::ObjectWrap<ClassType> {};
class ObjectWrap<realmjsi::Types, ClassType> : public realm::js::realmjsi::ObjectWrap<ClassType> {
};

template <realmjsi::ArgumentsMethodType F>
fbjsi::Value wrap(fbjsi::Runtime& rt, const fbjsi::Value& thisVal, const fbjsi::Value* args, size_t count)
Expand Down

0 comments on commit b80c02f

Please sign in to comment.