From 7c685d8d9cf2f366e66329df87351915da9970e9 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 20 Mar 2017 20:10:23 +0100 Subject: [PATCH] src: use persistent strings from node::Environment Replace a few calls to FIXED_ONE_BYTE_STRING() with their persistent counterparts from `node::Environment`. None of the calls are in hot code paths but why create a new string when one already exists? --- src/node_contextify.cc | 3 +-- src/node_crypto.cc | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 2e7c577cec7afc..a6e3d93aa820e3 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -743,8 +743,7 @@ class ContextifyScript : public BaseObject { return -1; } - Local key = FIXED_ONE_BYTE_STRING(env->isolate(), "timeout"); - Local value = options.As()->Get(key); + Local value = options.As()->Get(env->timeout_string()); if (value->IsUndefined()) { return -1; } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 700508067790de..9cf79a93fa9fdf 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2076,8 +2076,7 @@ void SSLWrap::VerifyError(const FunctionCallbackInfo& args) { Local reason_string = OneByteString(isolate, reason); Local exception_value = Exception::Error(reason_string); Local exception_object = exception_value->ToObject(isolate); - exception_object->Set(FIXED_ONE_BYTE_STRING(isolate, "code"), - OneByteString(isolate, code)); + exception_object->Set(w->env()->code_string(), OneByteString(isolate, code)); args.GetReturnValue().Set(exception_object); } @@ -3276,7 +3275,7 @@ void Connection::SetSNICallback(const FunctionCallbackInfo& args) { } Local obj = Object::New(env->isolate()); - obj->Set(FIXED_ONE_BYTE_STRING(args.GetIsolate(), "onselect"), args[0]); + obj->Set(env->onselect_string(), args[0]); conn->sniObject_.Reset(args.GetIsolate(), obj); } #endif @@ -5605,7 +5604,7 @@ void RandomBytes(const FunctionCallbackInfo& args) { RandomBytesRequest* req = new RandomBytesRequest(env, obj, size); if (args[1]->IsFunction()) { - obj->Set(FIXED_ONE_BYTE_STRING(args.GetIsolate(), "ondone"), args[1]); + obj->Set(env->ondone_string(), args[1]); if (env->in_domain()) obj->Set(env->domain_string(), env->domain_array()->Get(0));