- if (xbt_log_settings) {
- xbt_assert(category, "NULL category");
- xbt_assert(category->name);
- int found = 0;
-
- xbt_dynar_foreach(xbt_log_settings, cursor, setting) {
- xbt_assert(setting, "Damnit, NULL cat in the list");
- xbt_assert(setting->catname, "NULL setting(=%p)->catname", (void *) setting);
-
- if (!strcmp(setting->catname, category->name)) {
- found = 1;
- _xbt_log_cat_apply_set(category, setting);
- xbt_dynar_cursor_rm(xbt_log_settings, &cursor);
- }
- }
-
- if (!found)
- XBT_DEBUG("Category '%s': inherited threshold = %s (=%d)",
- category->name, xbt_log_priority_names[category->threshold], category->threshold);
+ auto iset = std::find_if(begin(xbt_log_settings), end(xbt_log_settings),
+ [category](const xbt_log_setting_t& s) { return s.catname == category->name; });
+ if (iset != xbt_log_settings.end()) {
+ _xbt_log_cat_apply_set(category, *iset);
+ xbt_log_settings.erase(iset);
+ } else {
+ XBT_DEBUG("Category '%s': inherited threshold = %s (=%d)", category->name,
+ xbt_log_priority_names[category->threshold], category->threshold);