mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-22 00:13:52 +01:00
3a4e841c73
Before this patch, multiple grids with disjoint regexes would result in no snapshots being destroyed at all. fixes #292
29 lines
607 B
Go
29 lines
607 B
Go
package pruning
|
|
|
|
func filterSnapList(snaps []Snapshot, predicate func(Snapshot) bool) []Snapshot {
|
|
r := make([]Snapshot, 0, len(snaps))
|
|
for i := range snaps {
|
|
if predicate(snaps[i]) {
|
|
r = append(r, snaps[i])
|
|
}
|
|
}
|
|
return r
|
|
}
|
|
|
|
func partitionSnapList(snaps []Snapshot, predicate func(Snapshot) bool) (sTrue, sFalse []Snapshot) {
|
|
for i := range snaps {
|
|
if predicate(snaps[i]) {
|
|
sTrue = append(sTrue, snaps[i])
|
|
} else {
|
|
sFalse = append(sFalse, snaps[i])
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func shallowCopySnapList(snaps []Snapshot) []Snapshot {
|
|
c := make([]Snapshot, len(snaps))
|
|
copy(c, snaps)
|
|
return c
|
|
}
|