[core] Make response data shared to avoid excessive copying

This commit is contained in:
Konstantin Käfer
2015-10-16 16:14:55 +02:00
parent 4e3503ea6c
commit 5173bf1bb8
33 changed files with 135 additions and 117 deletions

View File

@@ -110,10 +110,10 @@ NAN_METHOD(NodeRequest::Respond) {
if (Nan::Has(res, Nan::New("data").ToLocalChecked()).FromJust()) {
auto dataHandle = Nan::Get(res, Nan::New("data").ToLocalChecked()).ToLocalChecked();
if (node::Buffer::HasInstance(dataHandle)) {
response->data = std::string {
response->data = std::make_shared<std::string>(
node::Buffer::Data(dataHandle),
node::Buffer::Length(dataHandle)
};
);
} else {
return Nan::ThrowTypeError("Response data must be a Buffer");
}