mirror of https://github.com/vbatts/go-mtree.git
dont use slices
This commit is contained in:
parent
17374843eb
commit
b062bc1c68
|
@ -5,7 +5,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
cli "github.com/urfave/cli/v2"
|
cli "github.com/urfave/cli/v2"
|
||||||
|
@ -76,20 +75,21 @@ func mutateAction(c *cli.Context) error {
|
||||||
&tidyVisitor,
|
&tidyVisitor,
|
||||||
}
|
}
|
||||||
|
|
||||||
dropped := []int{}
|
dropped := map[int]bool{}
|
||||||
entries := []mtree.Entry{}
|
entries := []mtree.Entry{}
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
for _, entry := range spec.Entries {
|
for _, entry := range spec.Entries {
|
||||||
|
if entry.Parent != nil {
|
||||||
if entry.Parent != nil && slices.Contains(dropped, entry.Parent.Pos) {
|
if _, ok := dropped[entry.Parent.Pos]; ok {
|
||||||
if entry.Type == mtree.DotDotType {
|
if entry.Type == mtree.DotDotType {
|
||||||
// directory for this .. has been dropped so shall this
|
// directory for this .. has been dropped so shall this
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
entry.Parent = entry.Parent.Parent
|
||||||
|
// TODO: i am not sure if this is the correct behavior
|
||||||
|
entry.Raw = strings.TrimPrefix(entry.Raw, " ")
|
||||||
}
|
}
|
||||||
entry.Parent = entry.Parent.Parent
|
|
||||||
// TODO: i am not sure if this is the correct behavior
|
|
||||||
entry.Raw = strings.TrimPrefix(entry.Raw, " ")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, visitor := range visitors {
|
for _, visitor := range visitors {
|
||||||
|
@ -99,7 +99,7 @@ skip:
|
||||||
}
|
}
|
||||||
|
|
||||||
if drop {
|
if drop {
|
||||||
dropped = append(dropped, entry.Pos)
|
dropped[entry.Pos] = true
|
||||||
continue skip
|
continue skip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue