Skip to content

Commit 6a6c431

Browse files
bnoordhuisMylesBorins
authored andcommitted
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? PR-URL: #11945 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 41bec5c commit 6a6c431

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/node_contextify.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,7 @@ class ContextifyScript : public BaseObject {
722722
return -1;
723723
}
724724

725-
Local<String> key = FIXED_ONE_BYTE_STRING(env->isolate(), "timeout");
726-
Local<Value> value = options.As<Object>()->Get(key);
725+
Local<Value> value = options.As<Object>()->Get(env->timeout_string());
727726
if (value->IsUndefined()) {
728727
return -1;
729728
}

src/node_crypto.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -2055,8 +2055,7 @@ void SSLWrap<Base>::VerifyError(const FunctionCallbackInfo<Value>& args) {
20552055
Local<String> reason_string = OneByteString(isolate, reason);
20562056
Local<Value> exception_value = Exception::Error(reason_string);
20572057
Local<Object> exception_object = exception_value->ToObject(isolate);
2058-
exception_object->Set(FIXED_ONE_BYTE_STRING(isolate, "code"),
2059-
OneByteString(isolate, code));
2058+
exception_object->Set(w->env()->code_string(), OneByteString(isolate, code));
20602059
args.GetReturnValue().Set(exception_object);
20612060
}
20622061

@@ -3255,7 +3254,7 @@ void Connection::SetSNICallback(const FunctionCallbackInfo<Value>& args) {
32553254
}
32563255

32573256
Local<Object> obj = Object::New(env->isolate());
3258-
obj->Set(FIXED_ONE_BYTE_STRING(args.GetIsolate(), "onselect"), args[0]);
3257+
obj->Set(env->onselect_string(), args[0]);
32593258
conn->sniObject_.Reset(args.GetIsolate(), obj);
32603259
}
32613260
#endif
@@ -5583,7 +5582,7 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) {
55835582
RandomBytesRequest* req = new RandomBytesRequest(env, obj, size);
55845583

55855584
if (args[1]->IsFunction()) {
5586-
obj->Set(FIXED_ONE_BYTE_STRING(args.GetIsolate(), "ondone"), args[1]);
5585+
obj->Set(env->ondone_string(), args[1]);
55875586

55885587
if (env->in_domain())
55895588
obj->Set(env->domain_string(), env->domain_array()->Get(0));

0 commit comments

Comments
 (0)