feat: 优化ac自动机

This commit is contained in:
CaIon
2025-08-15 16:54:26 +08:00
parent 63e7fb697f
commit 215546a805
2 changed files with 62 additions and 11 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ func SensitiveWordReplace(text string, returnImmediately bool) (bool, []string,
return false, nil, text
}
checkText := strings.ToLower(text)
m := InitAc(setting.SensitiveWords)
m := getOrBuildAC(setting.SensitiveWords)
hits := m.MultiPatternSearch([]rune(checkText), returnImmediately)
if len(hits) > 0 {
words := make([]string, 0, len(hits))