@@ -186,6 +186,18 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
186
186
return result;
187
187
}
188
188
189
+ // helper function to get the number of components per type
190
+ std::array<bool , n_types> get_n_components_per_type () const {
191
+ std::array<bool , n_types> result{};
192
+ size_t idx{};
193
+ main_core::utils::run_functor_with_all_types_return_void<ComponentType...>(
194
+ [&result, this , &idx]<typename CompType>() {
195
+ result[idx] = this ->component_count <CompType>();
196
+ ++idx;
197
+ });
198
+ return result;
199
+ }
200
+
189
201
// helper function to add vectors of components
190
202
template <class CompType > void add_component (std::vector<typename CompType::InputType> const & components) {
191
203
add_component<CompType>(components.begin (), components.end ());
@@ -580,10 +592,9 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
580
592
581
593
// cache component update order where possible.
582
594
// the order for a cacheable (independent) component by definition is the same across all scenarios
583
- // TODO: (figueroa1395): don't use string lookup, it is slow
584
- std::map<std::string, Idx, std::less<>> const relevant_component_count_map = all_component_count ();
595
+ auto const relevant_component_count = get_n_components_per_type ();
585
596
auto const is_independent =
586
- main_core::is_update_independent<ComponentType...>(update_data, relevant_component_count_map );
597
+ main_core::is_update_independent<ComponentType...>(update_data, relevant_component_count );
587
598
all_scenarios_sequence = get_sequence_idx_map (update_data, 0 , is_independent);
588
599
589
600
return [&base_model, &exceptions, &infos, &calculation_fn, &result_data, &update_data,
0 commit comments