Skip to content
Permalink
Browse files

tls: refactor tls_wrap.cc

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 6, 2019
1 parent 342031e commit 634aac5b94c4c53a6073276182bad551b3f052a0
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/tls_wrap.cc
@@ -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

0 comments on commit 634aac5

Please sign in to comment.
You can’t perform that action at this time.