forked from TrueCloudLab/restic
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 {
|
if err != nil {
|
||||||
return false, false, err
|
return false, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasNegatedPattern := false
|
||||||
|
for _, pat := range patterns {
|
||||||
|
hasNegatedPattern = hasNegatedPattern || pat.isNegated
|
||||||
|
}
|
||||||
|
|
||||||
for _, pat := range patterns {
|
for _, pat := range patterns {
|
||||||
m, err := match(pat, strs)
|
m, err := match(pat, strs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -275,6 +281,11 @@ func list(patterns []Pattern, checkChildMatches bool, str string) (matched bool,
|
||||||
} else {
|
} else {
|
||||||
matched = matched || m
|
matched = matched || m
|
||||||
childMayMatch = childMayMatch || c
|
childMayMatch = childMayMatch || c
|
||||||
|
|
||||||
|
if matched && childMayMatch && !hasNegatedPattern {
|
||||||
|
// without negative patterns the result cannot change any more
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue