mirror of
https://github.com/restic/restic.git
synced 2025-01-03 05:35:43 +00:00
filter: short circuit if no negative patterns
This commit is contained in:
parent
2ee07ded2b
commit
cd190bee14
1 changed files with 11 additions and 0 deletions
|
@ -253,6 +253,12 @@ func list(patterns []Pattern, checkChildMatches bool, str string) (matched bool,
|
|||
if err != nil {
|
||||
return false, false, err
|
||||
}
|
||||
|
||||
hasNegatedPattern := false
|
||||
for _, pat := range patterns {
|
||||
hasNegatedPattern = hasNegatedPattern || pat.isNegated
|
||||
}
|
||||
|
||||
for _, pat := range patterns {
|
||||
m, err := match(pat, strs)
|
||||
if err != nil {
|
||||
|
@ -275,6 +281,11 @@ func list(patterns []Pattern, checkChildMatches bool, str string) (matched bool,
|
|||
} else {
|
||||
matched = matched || m
|
||||
childMayMatch = childMayMatch || c
|
||||
|
||||
if matched && childMayMatch && !hasNegatedPattern {
|
||||
// without negative patterns the result cannot change any more
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue