Skip to content

Commit

Permalink
src: skip costly pushing/popping if we pass zeroes as async context
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Dec 22, 2021
1 parent 752d75d commit adaa3f4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/api/callback.cc
Expand Up @@ -56,6 +56,12 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
CHECK_NOT_NULL(env);
env->PushAsyncCallbackScope();

// Skip costly pushing/popping if we pass zeroes as async context
if (async_context_.async_id == 0) {
pushed_ids_ = false;
return;
}

if (!env->can_call_into_js()) {
failed_ = true;
return;
Expand Down

0 comments on commit adaa3f4

Please sign in to comment.