src: replace FIXED_ONE_BYTE_STRING with Environment-cached strings

PR-URL: https://github.com/nodejs/node/pull/59891
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This commit is contained in:
Moonki Choi 2025-09-17 15:34:40 +09:00 committed by GitHub
parent 1ebe88f87c
commit db926dc1fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 13 deletions

View File

@ -72,8 +72,7 @@ void Realm::CreateProperties() {
CHECK(primordials->IsObject());
set_primordials(primordials.As<Object>());
Local<String> prototype_string =
FIXED_ONE_BYTE_STRING(isolate(), "prototype");
Local<String> prototype_string = env_->prototype_string();
#define V(EnvPropertyName, PrimordialsPropertyName) \
{ \

View File

@ -1240,9 +1240,7 @@ void DatabaseSync::CustomFunction(const FunctionCallbackInfo<Value>& args) {
argc = -1;
} else {
Local<Value> js_len;
if (!fn->Get(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "length"))
.ToLocal(&js_len)) {
if (!fn->Get(env->context(), env->length_string()).ToLocal(&js_len)) {
return;
}
argc = js_len.As<Int32>()->Value();
@ -1473,7 +1471,7 @@ void DatabaseSync::CreateSession(const FunctionCallbackInfo<Value>& args) {
Local<Object> options = args[0].As<Object>();
Local<String> table_key = FIXED_ONE_BYTE_STRING(env->isolate(), "table");
Local<String> table_key = env->table_string();
bool hasIt;
if (!options->HasOwnProperty(env->context(), table_key).To(&hasIt)) {
return;

View File

@ -738,11 +738,10 @@ static void Initialize(Local<Object> target,
Local<FunctionTemplate> length_getter =
FunctionTemplate::New(isolate, StorageLengthGetter);
ctor_tmpl->PrototypeTemplate()->SetAccessorProperty(
FIXED_ONE_BYTE_STRING(isolate, "length"),
length_getter,
Local<FunctionTemplate>(),
DontDelete);
ctor_tmpl->PrototypeTemplate()->SetAccessorProperty(env->length_string(),
length_getter,
Local<FunctionTemplate>(),
DontDelete);
SetProtoMethod(isolate, ctor_tmpl, "clear", Clear);
SetProtoMethodNoSideEffect(isolate, ctor_tmpl, "getItem", GetItem);

View File

@ -84,8 +84,7 @@ void LibuvStreamWrap::Initialize(Local<Object> target,
sw->InstanceTemplate()->Set(env->oncomplete_string(), v8::Null(isolate));
sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(isolate, "callback"),
v8::Null(isolate));
sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(isolate, "handle"),
v8::Null(isolate));
sw->InstanceTemplate()->Set(env->handle_string(), v8::Null(isolate));
sw->Inherit(AsyncWrap::GetConstructorTemplate(env));