mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-05 11:18:37 +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
|
||||
|
||||
// FullMatcherSet is an implementation of MatcherSet.
|
||||
// It uses a hash table to facilitate exact match lookup.
|
||||
type FullMatcherSet struct {
|
||||
matchers map[string]struct{}
|
||||
}
|
||||
|
||||
func NewFullMatcherSet() *FullMatcherSet {
|
||||
return &FullMatcherSet{
|
||||
matchers: make(map[string]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
// AddFullMatcher implements MatcherSetForFull.AddFullMatcher.
|
||||
func (s *FullMatcherSet) AddFullMatcher(matcher FullMatcher) {
|
||||
s.matchers[matcher.Pattern()] = struct{}{}
|
||||
}
|
||||
|
||||
// MatchAny implements MatcherSet.Any.
|
||||
func (s *FullMatcherSet) MatchAny(input string) bool {
|
||||
_, found := s.matchers[input]
|
||||
return found
|
||||
}
|
||||
Reference in New Issue
Block a user