Skip to content

Commit adaa3f4

Browse files
committed
src: skip costly pushing/popping if we pass zeroes as async context
1 parent 752d75d commit adaa3f4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/api/callback.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
5656
CHECK_NOT_NULL(env);
5757
env->PushAsyncCallbackScope();
5858

59+
// Skip costly pushing/popping if we pass zeroes as async context
60+
if (async_context_.async_id == 0) {
61+
pushed_ids_ = false;
62+
return;
63+
}
64+
5965
if (!env->can_call_into_js()) {
6066
failed_ = true;
6167
return;

0 commit comments

Comments
 (0)