Cleanup: simplify by using lo.FilterMap instead of separate calls to Filter and Map

This commit is contained in:
Stefan Haller 2026-03-22 16:42:00 +01:00
parent 706a6c0474
commit 4a8ab6f64e

View file

@ -324,12 +324,8 @@ func (self *Node[T]) GetPathsMatching(predicate func(*Node[T]) bool) []string {
}
func (self *Node[T]) GetFilePathsMatching(predicate func(*T) bool) []string {
matchingFileNodes := lo.Filter(self.GetLeaves(), func(node *Node[T], _ int) bool {
return predicate(node.File)
})
return lo.Map(matchingFileNodes, func(node *Node[T], _ int) string {
return node.GetPath()
return lo.FilterMap(self.GetLeaves(), func(node *Node[T], _ int) (string, bool) {
return node.GetPath(), predicate(node.File)
})
}