1
0
Fork 0
forked from suyu/suyu

fsmitm_romfsbuild: std::move std::vector instances in Build()

Avoids making copies of large std::vector instances where it's trivially
avoidable to do so.
This commit is contained in:
Lioncash 2018-09-26 17:25:14 -04:00
parent 7ecdaaf189
commit 861580f6d2

View file

@ -345,7 +345,7 @@ std::map<u64, VirtualFile> RomFSBuildContext::Build() {
std::vector<u8> header_data(sizeof(RomFSHeader)); std::vector<u8> header_data(sizeof(RomFSHeader));
std::memcpy(header_data.data(), &header, header_data.size()); std::memcpy(header_data.data(), &header, header_data.size());
out.emplace(0, std::make_shared<VectorVfsFile>(header_data)); out.emplace(0, std::make_shared<VectorVfsFile>(std::move(header_data)));
std::vector<u8> metadata(file_hash_table_size + file_table_size + dir_hash_table_size + std::vector<u8> metadata(file_hash_table_size + file_table_size + dir_hash_table_size +
dir_table_size); dir_table_size);
@ -358,7 +358,7 @@ std::map<u64, VirtualFile> RomFSBuildContext::Build() {
file_hash_table.size() * sizeof(u32)); file_hash_table.size() * sizeof(u32));
index += file_hash_table.size() * sizeof(u32); index += file_hash_table.size() * sizeof(u32);
std::memcpy(metadata.data() + index, file_table.data(), file_table.size()); std::memcpy(metadata.data() + index, file_table.data(), file_table.size());
out.emplace(header.dir_hash_table_ofs, std::make_shared<VectorVfsFile>(metadata)); out.emplace(header.dir_hash_table_ofs, std::make_shared<VectorVfsFile>(std::move(metadata)));
return out; return out;
} }