Make sure unordered map references aren't invalidated by reserving sufficient space

This commit is contained in:
Dan Paulat 2024-05-24 01:55:01 -05:00
parent 26a22d4e84
commit 8f4325f61a
7 changed files with 39 additions and 4 deletions

View file

@ -78,6 +78,8 @@ class PaletteSettings::Impl
public:
explicit Impl()
{
palette_.reserve(kPaletteKeys_.size());
for (const auto& name : kPaletteKeys_)
{
const std::string& defaultValue = kDefaultPalettes_.at(name);
@ -92,6 +94,9 @@ public:
variables_.push_back(&settingsVariable);
};
activeAlertColor_.reserve(kAlertColors_.size());
inactiveAlertColor_.reserve(kAlertColors_.size());
for (auto& alert : kAlertColors_)
{
std::string phenomenonCode = awips::GetPhenomenonCode(alert.first);