summaryrefslogtreecommitdiff
path: root/lib/maps/maputil.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-04-13 13:18:28 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-13 13:18:28 -0600
commitf37ad3c90dab9b77e7c2796e963f5992458ad4a4 (patch)
tree631f9de458b9b91b02fe07e2a812233a3ac20520 /lib/maps/maputil.go
parentc262f37c6a0ba64d39414b45fd54d172c50762c8 (diff)
parent7726e27f3b79e031fe9a9ea9504dea5df0327e02 (diff)
Merge branch 'lukeshu/fixes'
Diffstat (limited to 'lib/maps/maputil.go')
-rw-r--r--lib/maps/maputil.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/maps/maputil.go b/lib/maps/maputil.go
index 63e52a0..3b6691a 100644
--- a/lib/maps/maputil.go
+++ b/lib/maps/maputil.go
@@ -31,13 +31,20 @@ func HasKey[K comparable, V any](m map[K]V, k K) bool {
return has
}
-func HaveAnyKeysInCommon[K comparable, V1, V2 any](small map[K]V1, big map[K]V2) bool {
- if len(big) < len(small) {
- return HaveAnyKeysInCommon(big, small)
- }
- for v := range small {
- if _, ok := big[v]; ok {
- return true
+func HaveAnyKeysInCommon[K comparable, V1, V2 any](a map[K]V1, b map[K]V2) bool {
+ if len(a) < len(b) {
+ small, big := a, b
+ for v := range small {
+ if _, ok := big[v]; ok {
+ return true
+ }
+ }
+ } else {
+ small, big := b, a
+ for v := range small {
+ if _, ok := big[v]; ok {
+ return true
+ }
}
}
return false