From 771a03dfe3dba6ac3136bd4aa25525220e29b0ff Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 18 Aug 2017 21:58:25 -0700 Subject: src: fixup strings, reduce duplication PR-URL: https://github.com/nodejs/node/pull/14937 Reviewed-By: Anna Henningsen --- src/pipe_wrap.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/pipe_wrap.cc') diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 2185580b06..0daec0b144 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -44,6 +44,7 @@ using v8::FunctionTemplate; using v8::HandleScope; using v8::Local; using v8::Object; +using v8::String; using v8::Value; using AsyncHooks = Environment::AsyncHooks; @@ -67,7 +68,8 @@ void PipeWrap::Initialize(Local target, Environment* env = Environment::GetCurrent(context); Local t = env->NewFunctionTemplate(New); - t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe")); + Local pipeString = FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe"); + t->SetClassName(pipeString); t->InstanceTemplate()->SetInternalFieldCount(1); env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId); @@ -92,7 +94,7 @@ void PipeWrap::Initialize(Local target, env->SetProtoMethod(t, "setPendingInstances", SetPendingInstances); #endif - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe"), t->GetFunction()); + target->Set(pipeString, t->GetFunction()); env->set_pipe_constructor_template(t); // Create FunctionTemplate for PipeConnectWrap. @@ -103,9 +105,10 @@ void PipeWrap::Initialize(Local 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(), "PipeConnectWrap")); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"), - cwt->GetFunction()); + Local wrapString = + FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"); + cwt->SetClassName(wrapString); + target->Set(wrapString, cwt->GetFunction()); } -- cgit v1.2.3