"net"
"os"
"path/filepath"
+ "slices"
"sort"
"strings"
"unicode"
return false
}
- if len(a) != len(b) {
- return false
- }
-
- for i := range a {
- if a[i] != b[i] {
- return false
- }
- }
-
- return true
+ return slices.Equal(a, b)
}
// SliceToLower goes through the source slice and lowers all values.
return false
}
for i, m := range menuList {
- if !menuEqual(m, entry.in[i]) {
+ if !slices.Equal(m, entry.in[i]) {
return false
}
}
m map[string][]menuCacheEntry
}
-// menuEqual checks if two menus are equal.
-func menuEqual(m1, m2 Menu) bool {
- if len(m1) != len(m2) {
- return false
- }
-
- for i := range m1 {
- if m1[i] != m2[i] {
- return false
- }
- }
-
- return true
-}
-
// get retrieves a menu from the cache based on the provided key and menuLists.
// If the menu is not found, it applies the provided function and caches the result.
func (c *menuCache) get(key string, apply func(m Menu), menuLists ...Menu) (Menu, bool) {
package navigation
import (
+ "slices"
"sync"
"sync/atomic"
"testing"
l1.Unlock()
m2, c2 := c1.get("k1", nil, m)
c.Assert(c2, qt.Equals, true)
- c.Assert(menuEqual(m, m2), qt.Equals, true)
- c.Assert(menuEqual(m, menu), qt.Equals, true)
+ c.Assert(slices.Equal(m, m2), qt.Equals, true)
+ c.Assert(slices.Equal(m, menu), qt.Equals, true)
c.Assert(m, qt.Not(qt.IsNil))
l2.Lock()