From 83802dfead4938e6f98b4b9961b286e06ab78b18 Mon Sep 17 00:00:00 2001 From: hop311 Date: Mon, 8 Jan 2024 22:19:39 +0000 Subject: Added map_callback and expect_item_dictionary_reserve_length --- src/openvic-simulation/misc/Event.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/openvic-simulation/misc/Event.cpp') diff --git a/src/openvic-simulation/misc/Event.cpp b/src/openvic-simulation/misc/Event.cpp index eb5f7da..d6750c1 100644 --- a/src/openvic-simulation/misc/Event.cpp +++ b/src/openvic-simulation/misc/Event.cpp @@ -196,7 +196,9 @@ bool EventManager::load_event_file(IssueManager const& issue_manager, ast::NodeC bool EventManager::load_on_action_file(ast::NodeCPtr root) { bool ret = expect_dictionary([this](std::string_view identifier, ast::NodeCPtr node) -> bool { OnAction::weight_map_t weighted_events; - bool ret = expect_dictionary([this, &identifier, &weighted_events](std::string_view weight_str, ast::NodeCPtr event_node) -> bool { + bool ret = expect_dictionary_reserve_length( + weighted_events, + [this, &identifier, &weighted_events](std::string_view weight_str, ast::NodeCPtr event_node) -> bool { bool ret = false; uint64_t weight = StringUtils::string_to_uint64(weight_str, &ret); if (!ret) { @@ -208,7 +210,7 @@ bool EventManager::load_on_action_file(ast::NodeCPtr root) { ret &= expect_event_identifier(assign_variable_callback_pointer(event))(event_node); if (event != nullptr) { - ret &= weighted_events.emplace(event, weight).second; + ret &= map_callback(weighted_events, event)(weight); } else { Logger::warning( "Non-existing event ", event->get_identifier(), " loaded on action ", identifier, "with weight", -- cgit v1.2.3-56-ga3b1