Skip to content

Commit

Permalink
refactor: change can_match_on prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
qjerome committed Nov 13, 2024
1 parent 5a1ebee commit d621d6a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gene/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,22 +311,22 @@ impl CompiledRule {
}

#[inline(always)]
pub(crate) fn can_match_on(&self, src: &String, id: i64) -> bool {
pub(crate) fn can_match_on<S: AsRef<str>>(&self, src: S, id: i64) -> bool {
// we have no filter at all
if self.include_events.is_empty() && self.exclude_events.is_empty() {
return true;
}

// explicit event excluding logic
let opt_exclude = self.exclude_events.get(src);
let opt_exclude = self.exclude_events.get(src.as_ref());
if let Some(exclude) = opt_exclude {
// we definitely want to exclude that event
if exclude.contains(&id) {
return false;
}
}

let opt_include = self.include_events.get(src);
let opt_include = self.include_events.get(src.as_ref());
// we include if we have no include filter for this source
// but we have an exclude filter (that didn't match)
if opt_include.is_none() && opt_exclude.is_some() {
Expand Down

0 comments on commit d621d6a

Please sign in to comment.