mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 02:48:55 +00:00
filter: short circuit if no negative patterns
This commit is contained in:
parent
2ee07ded2b
commit
cd190bee14
@ -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 New Issue
Block a user