GeezerVison is showing github.com — src: use String::WriteV2() in TwoByteValue · nodejs/node@9ca4b46
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/util.cc +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -146,12 +146,10 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local<Value> value) { |
146 | 146 | Local<String> string; |
147 | 147 | if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return; |
148 | 148 |
|
149 | | - // Allocate enough space to include the null terminator |
150 | | - const size_t storage = string->Length() + 1; |
151 | | - AllocateSufficientStorage(storage); |
152 | | - |
153 | | - const int flags = String::NO_NULL_TERMINATION; |
154 | | - const int length = string->Write(isolate, out(), 0, storage, flags); |
| 149 | + // Allocate enough space to include the null terminator. |
| 150 | + const size_t length = string->Length(); |
| 151 | + AllocateSufficientStorage(length + 1); |
| 152 | + string->WriteV2(isolate, 0, length, out()); |
155 | 153 | SetLengthAndZeroTerminate(length); |
156 | 154 | } |
157 | 155 |
|
|