feat: 优化ac自动机

This commit is contained in:
CaIon committed 2025-08-15 16:54:26 +08:00
1 parent 63e7fb697f
commit 215546a805
2 files changed
+62 -11

No files matched your search

+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))