diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index f43193c3ce0905..e58f164ca5124a 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -1660,11 +1660,9 @@ void CanonicalizeIP(const FunctionCallbackInfo& args) { uv_inet_pton(af = AF_INET6, *ip, result) != 0) return; - char canonical_ip[INET6_ADDRSTRLEN]; + char canonical_ip[INET6_ADDRSTRLEN]{}; CHECK_EQ(0, uv_inet_ntop(af, result, canonical_ip, sizeof(canonical_ip))); - Local val = String::NewFromUtf8(isolate, canonical_ip) - .ToLocalChecked(); - args.GetReturnValue().Set(val); + args.GetReturnValue().Set(OneByteString(isolate, canonical_ip)); } void ConvertIpv6StringToBuffer(const FunctionCallbackInfo& args) { diff --git a/src/node_binding.cc b/src/node_binding.cc index e93f3312cc6425..16231e4f9acf81 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -685,8 +685,7 @@ void GetLinkedBinding(const FunctionCallbackInfo& args) { Local module = Object::New(env->isolate()); Local exports = Object::New(env->isolate()); - Local exports_prop = - String::NewFromUtf8Literal(env->isolate(), "exports"); + Local exports_prop = env->exports_string(); module->Set(env->context(), exports_prop, exports).Check(); if (mod->nm_context_register_func != nullptr) { diff --git a/src/node_buffer.cc b/src/node_buffer.cc index e8eae4eff51144..8d58dc000e3f94 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -72,7 +72,6 @@ using v8::Just; using v8::Local; using v8::Maybe; using v8::MaybeLocal; -using v8::NewStringType; using v8::Nothing; using v8::Number; using v8::Object; @@ -1307,12 +1306,9 @@ static void Btoa(const FunctionCallbackInfo& args) { written = simdutf::binary_to_base64(*stack_buf, out_len, buffer.out()); } - auto value = - String::NewFromOneByte(env->isolate(), - reinterpret_cast(buffer.out()), - NewStringType::kNormal, - written) - .ToLocalChecked(); + auto value = OneByteString( + env->isolate(), reinterpret_cast(buffer.out()), written); + return args.GetReturnValue().Set(value); } @@ -1362,12 +1358,9 @@ static void Atob(const FunctionCallbackInfo& args) { } if (result.error == simdutf::error_code::SUCCESS) { - auto value = - String::NewFromOneByte(env->isolate(), + auto value = OneByteString(env->isolate(), reinterpret_cast(buffer.out()), - NewStringType::kNormal, - result.count) - .ToLocalChecked(); + result.count); return args.GetReturnValue().Set(value); } diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 267c24f85ed15d..dbda7d2f653b38 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -330,10 +330,7 @@ void ICUErrorName(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsInt32()); UErrorCode status = static_cast(args[0].As()->Value()); - Local res; - if (String::NewFromUtf8(env->isolate(), u_errorName(status)).ToLocal(&res)) { - args.GetReturnValue().Set(res); - } + args.GetReturnValue().Set(OneByteString(env->isolate(), u_errorName(status))); } } // anonymous namespace diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 6d8d5da686d446..df2fb4bd3adf8b 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -707,10 +707,10 @@ Local SyncProcessRunner::BuildResultObject() { } if (term_signal_ > 0) - js_result->Set(context, env()->signal_string(), - String::NewFromUtf8(env()->isolate(), - signo_string(term_signal_)) - .ToLocalChecked()) + js_result + ->Set(context, + env()->signal_string(), + OneByteString(env()->isolate(), signo_string(term_signal_))) .Check(); else js_result->Set(context, env()->signal_string(),