From eb14dbd9cdce11dd9341616349066ef5fae6826b Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 8 Oct 2018 13:19:47 -0400 Subject: [PATCH] Set vector size with constructor --- include/openmc/hdf5_interface.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/openmc/hdf5_interface.h b/include/openmc/hdf5_interface.h index ea4284cb82..f0b3a245c7 100644 --- a/include/openmc/hdf5_interface.h +++ b/include/openmc/hdf5_interface.h @@ -162,8 +162,7 @@ void read_attribute(hid_t obj_id, const char* name, xt::xarray& arr) std::size_t size = 1; for (const auto x : shape) size *= x; - std::vector buffer; - buffer.resize(size); + std::vector buffer(size); // Read data from attribute read_attr(obj_id, name, H5TypeMap::type_id, buffer.data()); @@ -245,8 +244,7 @@ void read_dataset(hid_t dset, xt::xarray& arr, bool indep=false) std::size_t size = 1; for (const auto x : shape) size *= x; - std::vector buffer; - buffer.resize(size); + std::vector buffer(size); // Read data from attribute read_dataset(dset, nullptr, H5TypeMap::type_id, buffer.data(), indep); @@ -275,8 +273,7 @@ void read_dataset_as_shape(hid_t obj_id, const char* name, std::size_t size = 1; for (const auto x : arr.shape()) size *= x; - std::vector buffer; - buffer.resize(size); + std::vector buffer(size); // Read data from attribute read_dataset(dset, nullptr, H5TypeMap::type_id, buffer.data(), indep);