From 0e5e16b3d00434d5ecd478e472fe57049cd09d57 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Sat, 21 Oct 2023 16:49:07 +0200 Subject: [PATCH] main: remove redundant equal function --- main.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/main.go b/main.go index 180cb0a..23aa93d 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ import ( "time" "golang.org/x/crypto/bcrypt" + "golang.org/x/exp/slices" "github.com/mjl-/adns" @@ -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 != "" {