Merge pull request #401 from CopernicaMarketingSoftware/40169
Improve Table copy assignment operator
This commit is contained in:
commit
134ed73498
|
|
@ -67,8 +67,10 @@ Table &Table::operator=(const Table &table)
|
||||||
// loop through the table records
|
// loop through the table records
|
||||||
for (auto iter = table._fields.begin(); iter != table._fields.end(); iter++)
|
for (auto iter = table._fields.begin(); iter != table._fields.end(); iter++)
|
||||||
{
|
{
|
||||||
// add the field
|
// since a map is always ordered, we know that each element will
|
||||||
_fields[iter->first] = std::shared_ptr<Field>(iter->second->clone());
|
// 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
|
// done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue