mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-03 20:56:43 -06:00
Use try_emplace() instead of emplace()
Fix bug where emplace() did not update existing keys in the map. Instead use try_emplace() for efficient conditional construction and assignment.
This commit is contained in:
1 parent
aee9658269
commit
61e5a3dd7f
1 file changed
+5
-2
@@ -514,9 +514,12 @@ void GroupState<Scalar>::
|
||||
update_group_production_potential(const std::string& gname, Scalar oil_rate,
|
||||
Scalar gas_rate, Scalar water_rate)
|
||||
{
|
||||
this->production_group_potentials.emplace(
|
||||
gname, GroupPotential{oil_rate, gas_rate, water_rate}
|
||||
auto [it, inserted] = production_group_potentials.try_emplace(
|
||||
gname, oil_rate, gas_rate, water_rate
|
||||
);
|
||||
if (!inserted) {
|
||||
it->second = GroupPotential{oil_rate, gas_rate, water_rate};
|
||||
}
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
|
||||
Reference in new issue
Block a user