goldsmith/filter_util.go

32 lines
556 B
Go
Raw Normal View History

package goldsmith
type filterEntry struct {
filter Filter
index int
}
type filterStack []filterEntry
2024-02-20 00:26:41 +00:00
func (self *filterStack) accept(file File) bool {
for _, entry := range *self {
2024-02-20 00:26:41 +00:00
if entry.index >= file.Index() && !entry.filter.Accept(file) {
return false
}
}
return true
}
func (self *filterStack) push(filter Filter, index int) {
*self = append(*self, filterEntry{filter, index})
}
func (self *filterStack) pop() {
count := len(*self)
if count == 0 {
panic("attempted to pop empty filter stack")
}
*self = (*self)[:count-1]
}