diff options
author | James M Snell <jasnell@gmail.com> | 2017-08-19 07:58:25 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-08-23 20:35:19 +0300 |
commit | 771a03dfe3dba6ac3136bd4aa25525220e29b0ff (patch) | |
tree | 9276a1e18c07fcead1ce87a384a7a47e42f00d79 /src/tcp_wrap.cc | |
parent | 0ce54a7ec96431a088a15a5e24614428184497f0 (diff) |
src: fixup strings, reduce duplication
PR-URL: https://github.com/nodejs/node/pull/14937
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/tcp_wrap.cc')
-rw-r--r-- | src/tcp_wrap.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 4bee4b97097..e721108caec 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -71,11 +71,12 @@ void TCPWrap::Initialize(Local<Object> target, Environment* env = Environment::GetCurrent(context); Local<FunctionTemplate> t = env->NewFunctionTemplate(New); - t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCP")); + Local<String> tcpString = FIXED_ONE_BYTE_STRING(env->isolate(), "TCP"); + t->SetClassName(tcpString); t->InstanceTemplate()->SetInternalFieldCount(1); // Init properties - t->InstanceTemplate()->Set(String::NewFromUtf8(env->isolate(), "reading"), + t->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "reading"), Boolean::New(env->isolate(), false)); t->InstanceTemplate()->Set(env->owner_string(), Null(env->isolate())); t->InstanceTemplate()->Set(env->onread_string(), Null(env->isolate())); @@ -109,7 +110,7 @@ void TCPWrap::Initialize(Local<Object> target, env->SetProtoMethod(t, "setSimultaneousAccepts", SetSimultaneousAccepts); #endif - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCP"), t->GetFunction()); + target->Set(tcpString, t->GetFunction()); env->set_tcp_constructor_template(t); // Create FunctionTemplate for TCPConnectWrap. @@ -120,9 +121,10 @@ void TCPWrap::Initialize(Local<Object> target, auto cwt = FunctionTemplate::New(env->isolate(), constructor); cwt->InstanceTemplate()->SetInternalFieldCount(1); env->SetProtoMethod(cwt, "getAsyncId", AsyncWrap::GetAsyncId); - cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap")); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"), - cwt->GetFunction()); + Local<String> wrapString = + FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"); + cwt->SetClassName(wrapString); + target->Set(wrapString, cwt->GetFunction()); } |