feat: 优化ac自动机

This commit is contained in:
CaIon
2025-08-15 16:54:26 +08:00
parent eeb421513b
commit b57e97d2a1
2 changed files with 62 additions and 11 deletions

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