PR notes & linter

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
This commit is contained in:
Thomas Anderson 2024-04-24 18:47:22 +03:00
parent 0a9df2f181
commit 8eff14fee0
No known key found for this signature in database
GPG Key ID: 4BFC48FBBFBB935F
2 changed files with 6 additions and 3 deletions

View File

@ -52,7 +52,8 @@ func (cache stringMap) contains(searchString string) bool {
if idx < searchBucketLen { if idx < searchBucketLen {
blockRule := cache[searchLen][idx*searchLen : idx*searchLen+searchLen] blockRule := cache[searchLen][idx*searchLen : idx*searchLen+searchLen]
if blockRule == normalized { if blockRule == normalized {
log.PrefixedLog("stringMap").Debugf("block rule '%s' matched with '%s'", blockRule, searchString) log.PrefixedLog("string_map").Debugf("block rule '%s' matched with '%s'", blockRule, searchString)
return true return true
} }
} }
@ -136,7 +137,7 @@ func (cache regexCache) elementCount() int {
func (cache regexCache) contains(searchString string) bool { func (cache regexCache) contains(searchString string) bool {
for _, regex := range cache { for _, regex := range cache {
if regex.MatchString(searchString) { if regex.MatchString(searchString) {
log.PrefixedLog("regexCache").Debugf("regex '%s' matched with '%s'", regex, searchString) log.PrefixedLog("regex_cache").Debugf("regex '%s' matched with '%s'", regex, searchString)
return true return true
} }

View File

@ -115,6 +115,7 @@ func (n *parent) insert(key string, split SplitFunc) {
func (n *parent) hasParentOf(key string, split SplitFunc) bool { func (n *parent) hasParentOf(key string, split SplitFunc) bool {
searchString := key searchString := key
rule := "" rule := ""
for { for {
label, rest := split(key) label, rest := split(key)
rule = strings.Join([]string{label, rule}, ".") rule = strings.Join([]string{label, rule}, ".")
@ -144,8 +145,9 @@ func (n *parent) hasParentOf(key string, split SplitFunc) bool {
if matched { if matched {
rule = strings.Join([]string{child.String(), rule}, ".") rule = strings.Join([]string{child.String(), rule}, ".")
rule = strings.Trim(rule, ".") rule = strings.Trim(rule, ".")
log.PrefixedLog("Trie").Debugf("wildcard block rule '%s' matched with '%s'", rule, searchString) log.PrefixedLog("trie").Debugf("wildcard block rule '%s' matched with '%s'", rule, searchString)
} }
return matched return matched
} }
} }