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/tty_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/tty_wrap.cc')
-rw-r--r-- | src/tty_wrap.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index f3f1edfe5d3..88e9a982649 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -41,6 +41,7 @@ using v8::FunctionTemplate; using v8::Integer; using v8::Local; using v8::Object; +using v8::String; using v8::Value; @@ -49,8 +50,10 @@ void TTYWrap::Initialize(Local<Object> target, Local<Context> context) { Environment* env = Environment::GetCurrent(context); + Local<String> ttyString = FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"); + Local<FunctionTemplate> t = env->NewFunctionTemplate(New); - t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY")); + t->SetClassName(ttyString); t->InstanceTemplate()->SetInternalFieldCount(1); env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId); @@ -68,7 +71,7 @@ void TTYWrap::Initialize(Local<Object> target, env->SetMethod(target, "isTTY", IsTTY); env->SetMethod(target, "guessHandleType", GuessHandleType); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"), t->GetFunction()); + target->Set(ttyString, t->GetFunction()); env->set_tty_constructor_template(t); } |