Skip to content

Commit

Permalink
tls: refactor tls_wrap.cc
Browse files Browse the repository at this point in the history
Store the result of excetuting the function in variable. Instead of
excetuting it for multiple times.

PR-URL: #30303
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
artmaks authored and MylesBorins committed Nov 17, 2019
1 parent ab5bca3 commit ae5aa3e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1141,12 +1141,11 @@ void TLSWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "getServername", GetServername);
env->SetProtoMethod(t, "setServername", SetServername);

env->set_tls_wrap_constructor_function(
t->GetFunction(env->context()).ToLocalChecked());
Local<Function> fn = t->GetFunction(env->context()).ToLocalChecked();

target->Set(env->context(),
tlsWrapString,
t->GetFunction(env->context()).ToLocalChecked()).Check();
env->set_tls_wrap_constructor_function(fn);

target->Set(env->context(), tlsWrapString, fn).Check();
}

} // namespace node
Expand Down

0 comments on commit ae5aa3e

Please sign in to comment.