mirror of https://github.com/AxioDL/metaforce.git
STRG: Avoid unnecessary copies
Makes several functions significantly less copy intensive. See previous commit for reason.
This commit is contained in:
parent
3d0270cf82
commit
93f107cb79
|
@ -67,8 +67,8 @@ void STRG::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
|
||||||
writer.writeUint32Big(strCount);
|
writer.writeUint32Big(strCount);
|
||||||
|
|
||||||
atUint32 offset = 0;
|
atUint32 offset = 0;
|
||||||
for (const std::pair<DNAFourCC, std::vector<std::u16string>>& lang : langs) {
|
for (const auto& lang : langs) {
|
||||||
lang.first.write(writer);
|
DNAFourCC{lang.first}.write(writer);
|
||||||
writer.writeUint32Big(offset);
|
writer.writeUint32Big(offset);
|
||||||
offset += strCount * 4 + 4;
|
offset += strCount * 4 + 4;
|
||||||
atUint32 langStrCount = lang.second.size();
|
atUint32 langStrCount = lang.second.size();
|
||||||
|
@ -87,20 +87,22 @@ void STRG::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
atUint32 nameTableSz = names.size() * 8;
|
atUint32 nameTableSz = names.size() * 8;
|
||||||
for (const std::pair<std::string, int32_t>& name : names)
|
for (const auto& name : names) {
|
||||||
nameTableSz += name.first.size() + 1;
|
nameTableSz += name.first.size() + 1;
|
||||||
|
}
|
||||||
writer.writeUint32Big(names.size());
|
writer.writeUint32Big(names.size());
|
||||||
writer.writeUint32Big(nameTableSz);
|
writer.writeUint32Big(nameTableSz);
|
||||||
offset = names.size() * 8;
|
offset = names.size() * 8;
|
||||||
for (const std::pair<std::string, int32_t>& name : names) {
|
for (const auto& name : names) {
|
||||||
writer.writeUint32Big(offset);
|
writer.writeUint32Big(offset);
|
||||||
writer.writeInt32Big(name.second);
|
writer.writeInt32Big(name.second);
|
||||||
offset += name.first.size() + 1;
|
offset += name.first.size() + 1;
|
||||||
}
|
}
|
||||||
for (const std::pair<std::string, int32_t>& name : names)
|
for (const auto& name : names) {
|
||||||
writer.writeString(name.first);
|
writer.writeString(name.first);
|
||||||
|
}
|
||||||
|
|
||||||
for (const std::pair<DNAFourCC, std::vector<std::u16string>>& lang : langs) {
|
for (const auto& lang : langs) {
|
||||||
offset = strCount * 4;
|
offset = strCount * 4;
|
||||||
atUint32 langStrCount = lang.second.size();
|
atUint32 langStrCount = lang.second.size();
|
||||||
for (atUint32 s = 0; s < strCount; ++s) {
|
for (atUint32 s = 0; s < strCount; ++s) {
|
||||||
|
@ -128,11 +130,12 @@ void STRG::Enumerate<BigDNA::BinarySize>(size_t& __isz) {
|
||||||
|
|
||||||
__isz += 8;
|
__isz += 8;
|
||||||
__isz += names.size() * 8;
|
__isz += names.size() * 8;
|
||||||
for (const std::pair<std::string, int32_t>& name : names)
|
for (const auto& name : names) {
|
||||||
__isz += name.first.size() + 1;
|
__isz += name.first.size() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
size_t strCount = STRG::count();
|
size_t strCount = STRG::count();
|
||||||
for (const std::pair<DNAFourCC, std::vector<std::u16string>>& lang : langs) {
|
for (const auto& lang : langs) {
|
||||||
atUint32 langStrCount = lang.second.size();
|
atUint32 langStrCount = lang.second.size();
|
||||||
__isz += strCount * 4;
|
__isz += strCount * 4;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue