Geodata: Reduce memory usage again (#5975)

https://github.com/XTLS/Xray-core/pull/5975#issuecomment-4274779560
This commit is contained in:
Meow
2026-04-26 00:15:37 +08:00
committed by GitHub
parent 7cf25970de
commit bc590bcb56
16 changed files with 700 additions and 50 deletions
@@ -0,0 +1,24 @@
package strmatcher
import "strings"
// SubstrMatcherSet is implementation of MatcherSet,
// It is simply implmeneted to comply with the priority specification of Substr matchers.
type SubstrMatcherSet struct {
patterns []string
}
// AddSubstrMatcher implements MatcherSetForSubstr.AddSubstrMatcher.
func (s *SubstrMatcherSet) AddSubstrMatcher(matcher SubstrMatcher) {
s.patterns = append(s.patterns, matcher.Pattern())
}
// MatchAny implements MatcherSet.MatchAny.
func (s *SubstrMatcherSet) MatchAny(input string) bool {
for _, pattern := range s.patterns {
if strings.Contains(input, pattern) {
return true
}
}
return false
}