lib/ignore: Remove unused patterns in cache (#9601)

Tiny cleanup I noticed while trying to fix/test another issue
(https://github.com/syncthing/syncthing/pull/9600). I shortly tried to
figure out what it was used for in the past, but gave up without
results.
This commit is contained in:
Simon Frei 2024-07-02 13:01:00 +02:00 committed by GitHub
parent 403ce7e597
commit aea7fa5f22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 7 deletions

View File

@ -19,8 +19,7 @@ type nower interface {
var clock = nower(defaultClock{}) var clock = nower(defaultClock{})
type cache struct { type cache struct {
patterns []Pattern entries map[string]cacheEntry
entries map[string]cacheEntry
} }
type cacheEntry struct { type cacheEntry struct {
@ -28,10 +27,9 @@ type cacheEntry struct {
access int64 // Unix nanosecond count. Sufficient until the year 2262. access int64 // Unix nanosecond count. Sufficient until the year 2262.
} }
func newCache(patterns []Pattern) *cache { func newCache() *cache {
return &cache{ return &cache{
patterns: patterns, entries: make(map[string]cacheEntry),
entries: make(map[string]cacheEntry),
} }
} }

View File

@ -21,7 +21,7 @@ func TestCache(t *testing.T) {
clock = oldClock clock = oldClock
}() }()
c := newCache(nil) c := newCache()
res, ok := c.get("nonexistent") res, ok := c.get("nonexistent")
if res.IsIgnored() || res.IsDeletable() || ok { if res.IsIgnored() || res.IsDeletable() || ok {

View File

@ -205,7 +205,7 @@ func (m *Matcher) parseLocked(r io.Reader, file string) error {
m.curHash = newHash m.curHash = newHash
m.patterns = patterns m.patterns = patterns
if m.withCache { if m.withCache {
m.matches = newCache(patterns) m.matches = newCache()
} }
return err return err