Merge pull request #18 from torque/extradata-dedup

Perform extradata deduplication on add.
This commit is contained in:
Thomas Goyne 2014-08-24 16:53:23 -07:00
commit 375117c35c
1 changed files with 6 additions and 1 deletions

View File

@ -229,8 +229,13 @@ void AssFile::Sort(EntryList<AssDialogue> &lst, CompFunc comp, std::set<AssDialo
}
}
uint32_t AssFile::AddExtradata(std::string const& key, std::string const& value) {
for (auto const& data : Extradata) {
// perform brute-force deduplication by simple key and value comparison
if (key == data.second.first && value == data.second.second) {
return data.first;
}
}
// next_extradata_id must not exist
assert(Extradata.find(next_extradata_id) == Extradata.end());
Extradata[next_extradata_id] = {key, value};