src: use String::WriteV2() in TwoByteValue

Since `String::Write()` is deprecated, use `String::WriteV2()` instead.

PR-URL: https://github.com/nodejs/node/pull/58164
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Tobias Nießen 2025-05-09 04:15:47 +01:00 committed by GitHub
parent e46fb17ecb
commit 8debf0bddc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -146,12 +146,10 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local<Value> value) {
Local<String> string;
if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return;
// Allocate enough space to include the null terminator
const size_t storage = string->Length() + 1;
AllocateSufficientStorage(storage);
const int flags = String::NO_NULL_TERMINATION;
const int length = string->Write(isolate, out(), 0, storage, flags);
// Allocate enough space to include the null terminator.
const size_t length = string->Length();
AllocateSufficientStorage(length + 1);
string->WriteV2(isolate, 0, length, out());
SetLengthAndZeroTerminate(length);
}