From 8debf0bddcd8360e600b62eaf64c233361b70984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 9 May 2025 04:15:47 +0100 Subject: [PATCH] src: use String::WriteV2() in TwoByteValue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since `String::Write()` is deprecated, use `String::WriteV2()` instead. PR-URL: https://github.com/nodejs/node/pull/58164 Reviewed-By: Juan José Arboleda Reviewed-By: Joyee Cheung Reviewed-By: Yagiz Nizipli Reviewed-By: Daeyeon Jeong Reviewed-By: Gerhard Stöbich Reviewed-By: James M Snell --- src/util.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/util.cc b/src/util.cc index 1512f262fd9..78326b56eab 100644 --- a/src/util.cc +++ b/src/util.cc @@ -146,12 +146,10 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local value) { Local 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); }