Skip to content

Commit

Permalink
subtyping cache with strings to prevent memory leaking
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullinAM committed Jul 31, 2023
1 parent 4649c69 commit c479e71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/src/main/kotlin/org/vorpal/research/kex/util/kfg.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ fun Class.getCtor(vararg argTypes: Type) =
getMethod("<init>", cm.type.voidType, *argTypes)

private object SubTypeInfoCache {
private val subtypeCache = mutableMapOf<Pair<Type, Type>, Boolean>()
fun check(lhv: Type, rhv: Type): Boolean = subtypeCache.getOrPut(lhv to rhv) {
private val subtypeCache = mutableMapOf<Pair<String, String>, Boolean>()
fun check(lhv: Type, rhv: Type): Boolean = subtypeCache.getOrPut(lhv.toString() to rhv.toString()) {
lhv.isSubtypeOf(rhv)
}
}

fun Type.isSubtypeOfCached(other: Type): Boolean = SubTypeInfoCache.check(this, other)
fun Type.isSubtypeOfCached(other: Type): Boolean = this.isSubtypeOf(other)
2 changes: 1 addition & 1 deletion kex.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ def main() -> int:

if __name__ == "__main__":
returnCode = main()
sys.exit(returnCode)
sys.exit(returnCode)

0 comments on commit c479e71

Please sign in to comment.