diff --git a/src/RuleMatcher.cc b/src/RuleMatcher.cc index 220fa9019d1..ef3860748f8 100644 --- a/src/RuleMatcher.cc +++ b/src/RuleMatcher.cc @@ -657,7 +657,7 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state, const u } // Find rules for which patterns have matched. - set rule_matches; + map rule_matches; for ( AcceptingMatchSet::const_iterator it = accepted_matches.begin(); it != accepted_matches.end(); ++it ) { auto [aidx, mpos] = *it; @@ -665,11 +665,11 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state, const u Rule* r = Rule::rule_table[aidx - 1]; if ( AllRulePatternsMatched(r, mpos, accepted_matches) ) - rule_matches.insert(r); + rule_matches[r->Index()] = r; } - for ( set::const_iterator it = rule_matches.begin(); it != rule_matches.end(); ++it ) { - Rule* r = *it; + for ( const auto& entry : rule_matches ) { + Rule* r = entry.second; for ( const auto& action : r->actions ) { const RuleActionMIME* ram = dynamic_cast(action); @@ -841,7 +841,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, const // matched patterns per connection (which is a plausible assumption). // Find rules for which patterns have matched. - set> rule_matches; + map> rule_matches; for ( AcceptingMatchSet::const_iterator it = accepted_matches.begin(); it != accepted_matches.end(); ++it ) { AcceptIdx aidx = it->first; @@ -850,13 +850,12 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, const Rule* r = Rule::rule_table[aidx - 1]; if ( AllRulePatternsMatched(r, mpos, accepted_matches) ) - rule_matches.insert(make_pair(r, mpos)); + rule_matches[r->Index()] = make_pair(r, mpos); } // Check which of the matching rules really belong to any of our nodes. - - for ( set>::const_iterator it = rule_matches.begin(); it != rule_matches.end(); ++it ) { - auto [r, match_end_pos] = *it; + for ( const auto& entry : rule_matches ) { + auto [r, match_end_pos] = entry.second; DBG_LOG(DBG_RULES, "Accepted rule: %s", r->id);