make more use of generics

This commit is contained in:
Jesse Duffield 2022-03-19 12:26:30 +11:00
parent dde30fa104
commit c7a629c440
52 changed files with 3013 additions and 274 deletions

View file

@ -100,7 +100,7 @@ func (s *CommitFileNode) EveryFile(test func(file *models.CommitFile) bool) bool
})
}
func (n *CommitFileNode) Flatten(collapsedPaths map[string]bool) []*CommitFileNode {
func (n *CommitFileNode) Flatten(collapsedPaths *CollapsedPaths) []*CommitFileNode {
results := flatten(n, collapsedPaths)
nodes := make([]*CommitFileNode, len(results))
for i, result := range results {
@ -110,7 +110,7 @@ func (n *CommitFileNode) Flatten(collapsedPaths map[string]bool) []*CommitFileNo
return nodes
}
func (node *CommitFileNode) GetNodeAtIndex(index int, collapsedPaths map[string]bool) *CommitFileNode {
func (node *CommitFileNode) GetNodeAtIndex(index int, collapsedPaths *CollapsedPaths) *CommitFileNode {
if node == nil {
return nil
}
@ -124,11 +124,11 @@ func (node *CommitFileNode) GetNodeAtIndex(index int, collapsedPaths map[string]
return result.(*CommitFileNode)
}
func (node *CommitFileNode) GetIndexForPath(path string, collapsedPaths map[string]bool) (int, bool) {
func (node *CommitFileNode) GetIndexForPath(path string, collapsedPaths *CollapsedPaths) (int, bool) {
return getIndexForPath(node, path, collapsedPaths)
}
func (node *CommitFileNode) Size(collapsedPaths map[string]bool) int {
func (node *CommitFileNode) Size(collapsedPaths *CollapsedPaths) int {
if node == nil {
return 0
}