Skip to content

Commit ae5aa3e

Browse files
artmaksMylesBorins
authored andcommitted
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>
1 parent ab5bca3 commit ae5aa3e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/tls_wrap.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -1141,12 +1141,11 @@ void TLSWrap::Initialize(Local<Object> target,
11411141
env->SetProtoMethod(t, "getServername", GetServername);
11421142
env->SetProtoMethod(t, "setServername", SetServername);
11431143

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

1147-
target->Set(env->context(),
1148-
tlsWrapString,
1149-
t->GetFunction(env->context()).ToLocalChecked()).Check();
1146+
env->set_tls_wrap_constructor_function(fn);
1147+
1148+
target->Set(env->context(), tlsWrapString, fn).Check();
11501149
}
11511150

11521151
} // namespace node

0 commit comments

Comments
 (0)