Skip to content

Commit f35e80d

Browse files
bnoordhuisjasnell
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 64d0a73 commit f35e80d

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
@@ -743,8 +743,7 @@ class ContextifyScript : public BaseObject {
743743
return -1;
744744
}
745745

746-
Local<String> key = FIXED_ONE_BYTE_STRING(env->isolate(), "timeout");
747-
Local<Value> value = options.As<Object>()->Get(key);
746+
Local<Value> value = options.As<Object>()->Get(env->timeout_string());
748747
if (value->IsUndefined()) {
749748
return -1;
750749
}

src/node_crypto.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -2076,8 +2076,7 @@ void SSLWrap<Base>::VerifyError(const FunctionCallbackInfo<Value>& args) {
20762076
Local<String> reason_string = OneByteString(isolate, reason);
20772077
Local<Value> exception_value = Exception::Error(reason_string);
20782078
Local<Object> exception_object = exception_value->ToObject(isolate);
2079-
exception_object->Set(FIXED_ONE_BYTE_STRING(isolate, "code"),
2080-
OneByteString(isolate, code));
2079+
exception_object->Set(w->env()->code_string(), OneByteString(isolate, code));
20812080
args.GetReturnValue().Set(exception_object);
20822081
}
20832082

@@ -3276,7 +3275,7 @@ void Connection::SetSNICallback(const FunctionCallbackInfo<Value>& args) {
32763275
}
32773276

32783277
Local<Object> obj = Object::New(env->isolate());
3279-
obj->Set(FIXED_ONE_BYTE_STRING(args.GetIsolate(), "onselect"), args[0]);
3278+
obj->Set(env->onselect_string(), args[0]);
32803279
conn->sniObject_.Reset(args.GetIsolate(), obj);
32813280
}
32823281
#endif
@@ -5605,7 +5604,7 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) {
56055604
RandomBytesRequest* req = new RandomBytesRequest(env, obj, size);
56065605

56075606
if (args[1]->IsFunction()) {
5608-
obj->Set(FIXED_ONE_BYTE_STRING(args.GetIsolate(), "ondone"), args[1]);
5607+
obj->Set(env->ondone_string(), args[1]);
56095608

56105609
if (env->in_domain())
56115610
obj->Set(env->domain_string(), env->domain_array()->Get(0));

0 commit comments

Comments
 (0)