goldsmith/filter_util.go
Alex Yatskov e408fa9335 Squashed commit of the following:
commit 106991bfd59bb95977045399f7b4e5f4e7addc56
Author: Alex Yatskov <alex@foosoft.net>
Date:   Sat Jan 8 11:19:21 2022 -0800

    Rename property functions

commit 07f6033d4e86df257806af16de002ce8fad3d67f
Author: Alex Yatskov <alex@foosoft.net>
Date:   Sat Jan 8 11:16:46 2022 -0800

    Update rewrite

commit ea2dc0b4d223d54832752f0efd3eb46d81d17b50
Author: Alex Yatskov <alex@foosoft.net>
Date:   Fri Jan 7 22:47:17 2022 -0800

    Add more property methods

commit e2f7f8dc7ebc5b668539e8233e323a7c256eced2
Author: Alex Yatskov <alex@foosoft.net>
Date:   Fri Jan 7 22:39:23 2022 -0800

    Add step indexing

commit a7ed2a0b1c95ed9fbb0bbd87c779cf51a92f0b5f
Author: Alex Yatskov <alex@foosoft.net>
Date:   Fri Jan 7 20:50:19 2022 -0800

    Use self

commit 7ecc01e508c06680dcb6b6ecd4265a7f72e2c933
Author: Alex Yatskov <alex@foosoft.net>
Date:   Sun Aug 22 12:33:09 2021 -0700

    Cleanup

commit 87dd28a4c14b88bea061ca913f68e272cca787f9
Author: Alex Yatskov <alex@foosoft.net>
Date:   Sun Aug 22 12:09:41 2021 -0700

    Cleanup

commit 129130128d2a50f119c46f70e7cb70ef421892ff
Merge: 629fce0 e751d70
Author: Alex Yatskov <alex@foosoft.net>
Date:   Sat Aug 21 12:18:09 2021 -0700

    Merge branch 'master' into dev

commit 629fce06a8fca6810ec772f558d9ffabda016d01
Author: Alex Yatskov <alex@foosoft.net>
Date:   Sun Jun 27 19:34:53 2021 -0700

    Abstract metadata
2022-01-08 18:08:36 -08:00

32 lines
555 B
Go

package goldsmith
type filterEntry struct {
filter Filter
index int
}
type filterStack []filterEntry
func (self *filterStack) accept(file *File) bool {
for _, entry := range *self {
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]
}