diff --git a/utils/linkedhashmap/iterator.go b/utils/linkedhashmap/iterator.go index 27c4427bba2f..3b59787150e2 100644 --- a/utils/linkedhashmap/iterator.go +++ b/utils/linkedhashmap/iterator.go @@ -59,8 +59,9 @@ func (it *iterator[K, V]) Next() bool { // It's important to ensure that [it.next] is not nil // by not deleting elements that have not yet been iterated // over from [it.lh] - it.key = it.next.Value.(keyValue[K, V]).key - it.value = it.next.Value.(keyValue[K, V]).value + kv := it.next.Value.(keyValue[K, V]) + it.key = kv.key + it.value = kv.value it.next = it.next.Next() // Next time, return next element it.exhausted = it.next == nil return true diff --git a/utils/linkedhashmap/linkedhashmap.go b/utils/linkedhashmap/linkedhashmap.go index 25e04d85ba14..9730e97911de 100644 --- a/utils/linkedhashmap/linkedhashmap.go +++ b/utils/linkedhashmap/linkedhashmap.go @@ -108,7 +108,8 @@ func (lh *linkedHashmap[K, V]) put(key K, value V) { func (lh *linkedHashmap[K, V]) get(key K) (V, bool) { if e, ok := lh.entryMap[key]; ok { - return e.Value.(keyValue[K, V]).value, true + kv := e.Value.(keyValue[K, V]) + return kv.value, true } return utils.Zero[V](), false } @@ -126,14 +127,16 @@ func (lh *linkedHashmap[K, V]) len() int { func (lh *linkedHashmap[K, V]) oldest() (K, V, bool) { if val := lh.entryList.Front(); val != nil { - return val.Value.(keyValue[K, V]).key, val.Value.(keyValue[K, V]).value, true + kv := val.Value.(keyValue[K, V]) + return kv.key, kv.value, true } return utils.Zero[K](), utils.Zero[V](), false } func (lh *linkedHashmap[K, V]) newest() (K, V, bool) { if val := lh.entryList.Back(); val != nil { - return val.Value.(keyValue[K, V]).key, val.Value.(keyValue[K, V]).value, true + kv := val.Value.(keyValue[K, V]) + return kv.key, kv.value, true } return utils.Zero[K](), utils.Zero[V](), false }