Closes #16
This commit is contained in:
1 parent
c3d3bd51fb
commit
6d6ace4315
6 files changed
+86
-4
No files matched your search
@@ -89,12 +89,16 @@ namespace {
|
||||
DecodeDatabase::Storage::Storage(const std::vector<DecodeFrame> &definitions)
|
||||
: frames(definitions) {
|
||||
// Validate the complete snapshot before creating its lookup index.
|
||||
for (const DecodeFrame &frame: frames)
|
||||
std::unordered_set<FrameKey, FrameKeyHasher> keys;
|
||||
keys.reserve(frames.size());
|
||||
for (const DecodeFrame &frame: frames) {
|
||||
ValidateFrame(frame);
|
||||
if (!keys.insert(frame.GetKey()).second)
|
||||
throw std::invalid_argument("Duplicate runtime frame key");
|
||||
}
|
||||
frameIndexByKey.reserve(frames.size());
|
||||
for (std::size_t index = 0U; index < frames.size(); ++index) {
|
||||
if (!frameIndexByKey.emplace(frames[index].GetKey(), index).second)
|
||||
throw std::invalid_argument("Duplicate runtime frame key");
|
||||
frameIndexByKey.emplace(frames[index].GetKey(), index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user