tls: refactor tls_wrap.cc

Store the result of excetuting the function in variable. Instead of
excetuting it for multiple times.

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Artem Maksimov authored and Myles Borins committed 2019-11-16 23:59:11 -08:00
1 parent ab5bca379f
commit ae5aa3ee83
1 file changed
+4 -5
+4 -5
View File
@@ -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