diff options
author | hop311 <hop3114@gmail.com> | 2024-01-22 21:02:58 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-01-23 23:14:53 +0100 |
commit | 268a6948c0400905dfc335427395519689f067f5 (patch) | |
tree | b30e9b5774130552fe97e27deaf0370d83920c43 /src/openvic-simulation/pop/Pop.cpp | |
parent | d4e597da089a81f719a9c33b46111d1c2c590124 (diff) |
Added reserve_more, expect_dictionary_key[s|_map]_reserve_length[_and_default]reserve_more
Diffstat (limited to 'src/openvic-simulation/pop/Pop.cpp')
-rw-r--r-- | src/openvic-simulation/pop/Pop.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index d422038..643f313 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -273,10 +273,19 @@ bool PopManager::add_pop_type( return ret; } -void PopManager::reserve_pop_types(size_t count) { - stratas.reserve(stratas.size() + count); - pop_types.reserve(pop_types.size() + count); - delayed_parse_nodes.reserve(delayed_parse_nodes.size() + count); +void PopManager::reserve_all_pop_types(size_t size) { + reserve_more_stratas(size); + if (pop_types_are_locked()) { + Logger::error("Failed to reserve space for ", size, " pop types in PopManager - already locked!"); + } else { + reserve_more_pop_types(size); + reserve_more(delayed_parse_nodes, size); + } +} + +void PopManager::lock_all_pop_types() { + lock_stratas(); + lock_pop_types(); } static NodeCallback auto expect_needs_income(PopType::income_type_t& types) { |