Skip to content

Commit

Permalink
dont use slices
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Nov 1, 2023
1 parent 1737484 commit b062bc1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions cmd/gomtree/cmd/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"math"
"os"
"slices"
"strings"

cli "github.com/urfave/cli/v2"
Expand Down Expand Up @@ -76,20 +75,21 @@ func mutateAction(c *cli.Context) error {
&tidyVisitor,
}

dropped := []int{}
dropped := map[int]bool{}
entries := []mtree.Entry{}

skip:
for _, entry := range spec.Entries {

if entry.Parent != nil && slices.Contains(dropped, entry.Parent.Pos) {
if entry.Type == mtree.DotDotType {
// directory for this .. has been dropped so shall this
continue
if entry.Parent != nil {
if _, ok := dropped[entry.Parent.Pos]; ok {
if entry.Type == mtree.DotDotType {
// directory for this .. has been dropped so shall this
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 {
Expand All @@ -99,7 +99,7 @@ skip:
}

if drop {
dropped = append(dropped, entry.Pos)
dropped[entry.Pos] = true
continue skip
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/vbatts/go-mtree

go 1.18
go 1.17

require (
github.com/davecgh/go-spew v1.1.1
Expand Down

0 comments on commit b062bc1

Please sign in to comment.