Merge pull request #89 from lioncash/vi-vector

vi: Copy data directly into the std::vector within Parcel's ReadBlock function
merge-requests/60/head
bunnei 2018-01-17 23:52:40 +07:00 committed by GitHub
commit cf0daed0b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

@ -47,8 +47,9 @@ public:
} }
std::vector<u8> ReadBlock(size_t length) { std::vector<u8> ReadBlock(size_t length) {
std::vector<u8> data(length); const u8* const begin = buffer.data() + read_index;
std::memcpy(data.data(), buffer.data() + read_index, length); const u8* const end = begin + length;
std::vector<u8> data(begin, end);
read_index += length; read_index += length;
read_index = Common::AlignUp(read_index, 4); read_index = Common::AlignUp(read_index, 4);
return data; return data;