getParts needs to copy the parts until a better interface can replace this

This commit is contained in:
uNetworkingAB
2025-11-28 03:55:49 +01:00
committed by GitHub
parent 6499438b41
commit ff48755d2f

View File

@@ -74,7 +74,7 @@ void uWS_getParts(const FunctionCallbackInfo<Value> &args) {
std::string_view part = optionalPart.value();
Local<ArrayBuffer> partArrayBuffer = ArrayBuffer_New(isolate, (void *) part.data(), part.length());
Local<ArrayBuffer> partArrayBuffer = ArrayBuffer_NewCopy(isolate, (void *) part.data(), part.length());
/* Map is 30% faster in this case, but a static Object could be faster still */
Local<Object> partMap = Object::New(isolate);
partMap->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "data", NewStringType::kNormal).ToLocalChecked(), partArrayBuffer).IsNothing();