From 70cfaa5412db6a914324bb605ba5576a2350227a Mon Sep 17 00:00:00 2001 From: Artem Maksimov Date: Wed, 6 Nov 2019 15:35:21 +0300 Subject: [PATCH] tls: refactoring tls_wrap.cc Store the result of excetuting the function in variable. Instead of excetuting it for multiple times. --- 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