Merge pull request #401 from CopernicaMarketingSoftware/40169

Improve Table copy assignment operator
This commit is contained in:
Emiel Bruijntjes 2021-07-01 12:54:20 +02:00 committed by GitHub
commit 134ed73498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -67,8 +67,10 @@ Table &Table::operator=(const Table &table)
// loop through the table records
for (auto iter = table._fields.begin(); iter != table._fields.end(); iter++)
{
// add the field
_fields[iter->first] = std::shared_ptr<Field>(iter->second->clone());
// since a map is always ordered, we know that each element will
// be inserted at the end of the new map, so we can simply use
// emplace_hint and hint at insertion at the end of the map
_fields.insert(_fields.end(), std::make_pair(iter->first, iter->second->clone()));
}
// done