File tree Expand file tree Collapse file tree 3 files changed +6
-29
lines changed Expand file tree Collapse file tree 3 files changed +6
-29
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
2020 "net"
2121 "os"
2222 "path/filepath"
23+ "slices"
2324 "sort"
2425 "strings"
2526 "unicode"
@@ -228,17 +229,7 @@ func compareStringSlices(a, b []string) bool {
228229 return false
229230 }
230231
231- if len (a ) != len (b ) {
232- return false
233- }
234-
235- for i := range a {
236- if a [i ] != b [i ] {
237- return false
238- }
239- }
240-
241- return true
232+ return slices .Equal (a , b )
242233}
243234
244235// SliceToLower goes through the source slice and lowers all values.
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ func (entry menuCacheEntry) matches(menuList []Menu) bool {
2828 return false
2929 }
3030 for i , m := range menuList {
31- if ! menuEqual (m , entry .in [i ]) {
31+ if ! slices . Equal (m , entry .in [i ]) {
3232 return false
3333 }
3434 }
@@ -46,21 +46,6 @@ type menuCache struct {
4646 m map [string ][]menuCacheEntry
4747}
4848
49- // menuEqual checks if two menus are equal.
50- func menuEqual (m1 , m2 Menu ) bool {
51- if len (m1 ) != len (m2 ) {
52- return false
53- }
54-
55- for i := range m1 {
56- if m1 [i ] != m2 [i ] {
57- return false
58- }
59- }
60-
61- return true
62- }
63-
6449// get retrieves a menu from the cache based on the provided key and menuLists.
6550// If the menu is not found, it applies the provided function and caches the result.
6651func (c * menuCache ) get (key string , apply func (m Menu ), menuLists ... Menu ) (Menu , bool ) {
Original file line number Diff line number Diff line change 1414package navigation
1515
1616import (
17+ "slices"
1718 "sync"
1819 "sync/atomic"
1920 "testing"
@@ -64,8 +65,8 @@ func TestMenuCache(t *testing.T) {
6465 l1 .Unlock ()
6566 m2 , c2 := c1 .get ("k1" , nil , m )
6667 c .Assert (c2 , qt .Equals , true )
67- c .Assert (menuEqual (m , m2 ), qt .Equals , true )
68- c .Assert (menuEqual (m , menu ), qt .Equals , true )
68+ c .Assert (slices . Equal (m , m2 ), qt .Equals , true )
69+ c .Assert (slices . Equal (m , menu ), qt .Equals , true )
6970 c .Assert (m , qt .Not (qt .IsNil ))
7071
7172 l2 .Lock ()
You can’t perform that action at this time.
0 commit comments