fix: inline vector allocation (#13449)

* fix: inline vector allocation

* remove size_t static cast
This commit is contained in:
Shelley Vohr 2018-06-27 12:57:10 -07:00 committed by GitHub
parent 28d148b475
commit e9971173d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 10 deletions

View file

@ -239,10 +239,9 @@ void GetUploadData(base::ListValue* upload_data_list,
if (reader->AsBytesReader()) {
const net::UploadBytesElementReader* bytes_reader =
reader->AsBytesReader();
auto vec =
auto bytes = std::make_unique<base::Value>(
std::vector<char>(bytes_reader->bytes(),
bytes_reader->bytes() + bytes_reader->length());
auto bytes = std::make_unique<base::Value>(vec);
bytes_reader->bytes() + bytes_reader->length()));
upload_data_dict->Set("bytes", std::move(bytes));
} else if (reader->AsFileReader()) {
const net::UploadFileElementReader* file_reader = reader->AsFileReader();

View file

@ -26,10 +26,8 @@ Converter<scoped_refptr<network::ResourceRequestBody>>::ToV8(
auto post_data_dict = std::make_unique<base::DictionaryValue>();
auto type = element.type();
if (type == network::DataElement::TYPE_BYTES) {
auto vec = std::vector<char>(
element.bytes(),
element.bytes() + static_cast<size_t>(element.length()));
auto bytes = std::make_unique<base::Value>(vec);
auto bytes = std::make_unique<base::Value>(std::vector<char>(
element.bytes(), element.bytes() + (element.length())));
post_data_dict->SetString("type", "rawData");
post_data_dict->Set("bytes", std::move(bytes));
} else if (type == network::DataElement::TYPE_FILE) {

View file

@ -419,10 +419,9 @@ base::Value* V8ValueConverter::FromV8Array(v8::Local<v8::Array> val,
base::Value* V8ValueConverter::FromNodeBuffer(v8::Local<v8::Value> value,
FromV8ValueState* state,
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::Length(value));
return std::make_unique<base::Value>(vec).release();
node::Buffer::Data(value) + node::Buffer::Length(value)));
}
base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,