Skip to content

Commit 3b9f92f

Browse files
committed
[optimize] 提供标记位获取匹配到的前缀,不做敏感词替换
1 parent 9a463e4 commit 3b9f92f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pkg/utils/xcollection/trie.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import "sync"
2323
// rune 42 stands for *
2424
const defaultMask = 42
2525

26+
// rune 0 stands for ""
27+
const emptyMask = 0
28+
2629
type (
2730
TrieOption func(root *Trie)
2831

@@ -182,6 +185,11 @@ func (t *Trie) deepRead(node *trieNode, words []string, parentWord string) (keyw
182185

183186
// replaceWithMask replace keyword with mask
184187
func (t *Trie) replaceWithMask(chars []rune, start, end int) {
188+
// if mask equal "" need not to replace
189+
if t.mask == emptyMask {
190+
return
191+
}
192+
185193
for i := start; i < end; i++ {
186194
chars[i] = t.mask
187195
}

0 commit comments

Comments
 (0)