From 634aac5b94c4c53a6073276182bad551b3f052a0 Mon Sep 17 00:00:00 2001 From: Artem Maksimov Date: Wed, 6 Nov 2019 15:35:21 +0300 Subject: [PATCH] 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 Reviewed-By: Richard Lau Reviewed-By: David Carlier Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- src/tls_wrap.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 2d36c1a2654aa6..42b9469e38189f 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -1141,12 +1141,11 @@ void TLSWrap::Initialize(Local target, env->SetProtoMethod(t, "getServername", GetServername); env->SetProtoMethod(t, "setServername", SetServername); - env->set_tls_wrap_constructor_function( - t->GetFunction(env->context()).ToLocalChecked()); + Local 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