fix: inline vector allocation (#13449)
* fix: inline vector allocation * remove size_t static cast
This commit is contained in:
parent
28d148b475
commit
e9971173d4
3 changed files with 6 additions and 10 deletions
|
@ -239,10 +239,9 @@ void GetUploadData(base::ListValue* upload_data_list,
|
||||||
if (reader->AsBytesReader()) {
|
if (reader->AsBytesReader()) {
|
||||||
const net::UploadBytesElementReader* bytes_reader =
|
const net::UploadBytesElementReader* bytes_reader =
|
||||||
reader->AsBytesReader();
|
reader->AsBytesReader();
|
||||||
auto vec =
|
auto bytes = std::make_unique<base::Value>(
|
||||||
std::vector<char>(bytes_reader->bytes(),
|
std::vector<char>(bytes_reader->bytes(),
|
||||||
bytes_reader->bytes() + bytes_reader->length());
|
bytes_reader->bytes() + bytes_reader->length()));
|
||||||
auto bytes = std::make_unique<base::Value>(vec);
|
|
||||||
upload_data_dict->Set("bytes", std::move(bytes));
|
upload_data_dict->Set("bytes", std::move(bytes));
|
||||||
} else if (reader->AsFileReader()) {
|
} else if (reader->AsFileReader()) {
|
||||||
const net::UploadFileElementReader* file_reader = reader->AsFileReader();
|
const net::UploadFileElementReader* file_reader = reader->AsFileReader();
|
||||||
|
|
|
@ -26,10 +26,8 @@ Converter<scoped_refptr<network::ResourceRequestBody>>::ToV8(
|
||||||
auto post_data_dict = std::make_unique<base::DictionaryValue>();
|
auto post_data_dict = std::make_unique<base::DictionaryValue>();
|
||||||
auto type = element.type();
|
auto type = element.type();
|
||||||
if (type == network::DataElement::TYPE_BYTES) {
|
if (type == network::DataElement::TYPE_BYTES) {
|
||||||
auto vec = std::vector<char>(
|
auto bytes = std::make_unique<base::Value>(std::vector<char>(
|
||||||
element.bytes(),
|
element.bytes(), element.bytes() + (element.length())));
|
||||||
element.bytes() + static_cast<size_t>(element.length()));
|
|
||||||
auto bytes = std::make_unique<base::Value>(vec);
|
|
||||||
post_data_dict->SetString("type", "rawData");
|
post_data_dict->SetString("type", "rawData");
|
||||||
post_data_dict->Set("bytes", std::move(bytes));
|
post_data_dict->Set("bytes", std::move(bytes));
|
||||||
} else if (type == network::DataElement::TYPE_FILE) {
|
} else if (type == network::DataElement::TYPE_FILE) {
|
||||||
|
|
|
@ -419,10 +419,9 @@ base::Value* V8ValueConverter::FromV8Array(v8::Local<v8::Array> val,
|
||||||
base::Value* V8ValueConverter::FromNodeBuffer(v8::Local<v8::Value> value,
|
base::Value* V8ValueConverter::FromNodeBuffer(v8::Local<v8::Value> value,
|
||||||
FromV8ValueState* state,
|
FromV8ValueState* state,
|
||||||
v8::Isolate* isolate) const {
|
v8::Isolate* isolate) const {
|
||||||
auto vec = std::vector<char>(
|
return new base::Value(std::vector<char>(
|
||||||
node::Buffer::Data(value),
|
node::Buffer::Data(value),
|
||||||
node::Buffer::Data(value) + node::Buffer::Length(value));
|
node::Buffer::Data(value) + node::Buffer::Length(value)));
|
||||||
return std::make_unique<base::Value>(vec).release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
|
base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
|
||||||
|
|
Loading…
Reference in a new issue