Skip to content

Commit

Permalink
main: remove redundant equal function
Browse files Browse the repository at this point in the history
  • Loading branch information
mpldr committed Oct 21, 2023
1 parent 08995c7 commit 0e5e16b
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"time"

"golang.org/x/crypto/bcrypt"
"golang.org/x/exp/slices"

"github.com/mjl-/adns"

Expand Down Expand Up @@ -280,28 +281,16 @@ If a single command matches, its usage and full help text is printed.
c.Usage()
}

equal := func(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}

prefix := func(l, pre []string) bool {
if len(pre) > len(l) {
return false
}
return equal(pre, l[:len(pre)])
return slices.Equal(pre, l[:len(pre)])
}

var partial []cmd
for _, c := range cmds {
if equal(c.words, args) {
if slices.Equal(c.words, args) {
c.gather()
fmt.Print(c.makeUsage())
if c.help != "" {
Expand Down

0 comments on commit 0e5e16b

Please sign in to comment.