diff --git a/main.cpp b/main.cpp index 7b7fd48d..6e3f7b57 100644 --- a/main.cpp +++ b/main.cpp @@ -1726,20 +1726,14 @@ struct memory_access { // write a vector of types that have a raw_type_mapping template void write_vector(uint32_t addr, vector &v) { assert(v.size()); - vector::access_type> buffer(v.size()); - for(const auto &e : v) { - buffer.push_back(e); - } - write(addr, (uint8_t *)buffer.data(), v.size() * sizeof(typename raw_type_mapping::access_type)); + write(addr, (uint8_t *)v.data(), v.size() * sizeof(typename raw_type_mapping::access_type)); } template void read_into_vector(uint32_t addr, unsigned int count, vector &v, bool zero_fill = false) { - vector::access_type> buffer(count); - if (count) read(addr, (uint8_t *)buffer.data(), count * sizeof(typename raw_type_mapping::access_type), zero_fill); v.clear(); - v.reserve(count); - for(const auto &e : buffer) { - v.push_back(e); + v.resize(count); + if (count) { + read(addr, (uint8_t *)v.data(), count * sizeof(typename raw_type_mapping::access_type), zero_fill); } } };