mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-02 17:58:46 +00:00
Geodata: Reduce memory usage again (#5975)
https://github.com/XTLS/Xray-core/pull/5975#issuecomment-4274779560
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user