Merge pull request #5008 from SpiritCroc/globstar
Speed up event match regex evaluation for big messages
This commit is contained in:
commit
63b3def667
|
@ -0,0 +1 @@
|
|||
Big messages taking inappropriately long to evaluate .m.rule.roomnotif push rules
|
|
@ -56,7 +56,12 @@ class EventMatchCondition(
|
|||
if (wordsOnly) {
|
||||
value.caseInsensitiveFind(pattern)
|
||||
} else {
|
||||
val modPattern = if (pattern.hasSpecialGlobChar()) pattern.simpleGlobToRegExp() else "*$pattern*".simpleGlobToRegExp()
|
||||
val modPattern = if (pattern.hasSpecialGlobChar())
|
||||
// Regex.containsMatchIn() is way faster without leading and trailing
|
||||
// stars, that don't make any difference for the evaluation result
|
||||
pattern.removePrefix("*").removeSuffix("*").simpleGlobToRegExp()
|
||||
else
|
||||
pattern.simpleGlobToRegExp()
|
||||
val regex = Regex(modPattern, RegexOption.DOT_MATCHES_ALL)
|
||||
regex.containsMatchIn(value)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue