From 9da4ee15186ffee25e53c13e3e64e251a11391e6 Mon Sep 17 00:00:00 2001 From: Valentyn Sobol Date: Mon, 16 Dec 2024 17:56:30 +0300 Subject: [PATCH] minor --- .../set/primitive/USymbolicSetUnionAdapter.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/usvm-core/src/main/kotlin/org/usvm/collection/set/primitive/USymbolicSetUnionAdapter.kt b/usvm-core/src/main/kotlin/org/usvm/collection/set/primitive/USymbolicSetUnionAdapter.kt index 35f383711..cb3002194 100644 --- a/usvm-core/src/main/kotlin/org/usvm/collection/set/primitive/USymbolicSetUnionAdapter.kt +++ b/usvm-core/src/main/kotlin/org/usvm/collection/set/primitive/USymbolicSetUnionAdapter.kt @@ -76,15 +76,19 @@ sealed class USymbolicSetUnionAdapter< this(WeakReference(key), composer?.let { WeakReference(it) }, result) fun containsCachedValue(key: Key, composer: UComposer<*, *>?): Boolean { - val thisKey = this.key.get() ?: return false - if (thisKey != key) return false + if (!this.key.equalTo(key)) return false - if (composer == null) { - return this.composer == null - } + val thisComposer = this.composer ?: return composer == null + if (composer == null) return false + + return thisComposer.equalTo(composer) + } - val thisComposer = this.composer?.get() ?: return false - return thisComposer == composer + companion object { + private fun WeakReference.equalTo(other: T): Boolean { + val value = get() ?: return false + return value == other + } } } }