Perform extradata deduplication on add.

Checks all existing extradata keys and values to ensure that the set
that is being added doesn't already exist.
This commit is contained in:
torque 2014-08-24 12:06:22 -07:00
parent d7fe7e3580
commit 3c12fc69f3

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};