summaryrefslogtreecommitdiff
path: root/src/pipe_wrap.cc
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-08-18 21:58:25 -0700
committerJames M Snell <jasnell@gmail.com>2017-08-23 10:35:19 -0700
commit771a03dfe3dba6ac3136bd4aa25525220e29b0ff (patch)
tree9276a1e18c07fcead1ce87a384a7a47e42f00d79 /src/pipe_wrap.cc
parent0ce54a7ec96431a088a15a5e24614428184497f0 (diff)
downloadandroid-node-v8-771a03dfe3dba6ac3136bd4aa25525220e29b0ff.tar.gz
android-node-v8-771a03dfe3dba6ac3136bd4aa25525220e29b0ff.tar.bz2
android-node-v8-771a03dfe3dba6ac3136bd4aa25525220e29b0ff.zip
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/pipe_wrap.cc')
-rw-r--r--src/pipe_wrap.cc13
1 files changed, 8 insertions, 5 deletions
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<Object> target,
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
- t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe"));
+ Local<String> 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<Object> 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<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(), "PipeConnectWrap"));
- target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"),
- cwt->GetFunction());
+ Local<String> wrapString =
+ FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap");
+ cwt->SetClassName(wrapString);
+ target->Set(wrapString, cwt->GetFunction());
}