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 <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • 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.