Skip to content

Commit bc9997d

Browse files
committed
refactor: remove unnecessary NapiScope instances in CallbackHandlers
1 parent fb57b8b commit bc9997d

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

test-app/runtime/src/main/cpp/runtime/callbackhandlers/CallbackHandlers.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,6 @@ CallbackHandlers::GetMethodOverrides(napi_env env, JEnv &jEnv, napi_value implem
706706
}
707707

708708
napi_value CallbackHandlers::RunOnMainThreadCallback(napi_env env, napi_callback_info info) {
709-
710-
NapiScope scope(env);
711-
712709
size_t argc = 1;
713710
napi_value args[1];
714711
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
@@ -973,12 +970,12 @@ napi_value CallbackHandlers::CallJSMethod(napi_env env, JNIEnv *_jEnv,
973970

974971
#ifndef __HERMES__
975972
auto runtime = Runtime::GetRuntime(env);
976-
method = runtime->js_method_cache->getCachedMethod(javaObjectId,methodName);
973+
method = runtime->js_method_cache->getCachedMethod(javaObjectId, methodName);
977974
if (!method) {
978975
#endif
979976
napi_get_named_property(env, jsObject, methodName.c_str(), &method);
980977
#ifndef __HERMES__
981-
if (!napi_util::is_null_or_undefined(env, method)) {
978+
if (napi_util::is_of_type(env, method, napi_function)) {
982979
runtime->js_method_cache->cacheMethod(javaObjectId, methodName, method);
983980
}
984981
}
@@ -1121,7 +1118,6 @@ void CallbackHandlers::PostCallback(napi_env env, napi_callback_info info,
11211118

11221119
napi_value CallbackHandlers::PostFrameCallback(napi_env env, napi_callback_info info) {
11231120
if (android_get_device_api_level() >= 24) {
1124-
NapiScope scope(env);
11251121
InitChoreographer();
11261122

11271123
size_t argc = 2;
@@ -1182,7 +1178,6 @@ napi_value CallbackHandlers::PostFrameCallback(napi_env env, napi_callback_info
11821178

11831179
napi_value CallbackHandlers::RemoveFrameCallback(napi_env env, napi_callback_info info) {
11841180
if (android_get_device_api_level() >= 24) {
1185-
NapiScope scope(env);
11861181
InitChoreographer();
11871182

11881183
size_t argc = 1;

0 commit comments

Comments
 (0)