Skip to content

Commit 2e348fd

Browse files
committed
add index for callees
1 parent 71892b4 commit 2e348fd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/graph/EtsApplicationGraph.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ class EtsApplicationGraphImpl(
104104
.flatMap { it.methods }
105105
.groupByTo(hashMapOf()) { it.name }
106106
}
107+
private val classMethodsByName by lazy {
108+
projectClassesBySignature.mapValues { (_, clazz) ->
109+
clazz.single().methods.groupBy { it.name }
110+
}
111+
}
107112

108113
private val cacheClassWithIdealSignature: MutableMap<EtsClassSignature, Maybe<EtsClass>> = hashMapOf()
109114
private val cacheMethodWithIdealSignature: MutableMap<EtsMethodSignature, Maybe<EtsMethod>> = hashMapOf()
@@ -227,11 +232,8 @@ class EtsApplicationGraphImpl(
227232

228233
// If the complete signature match failed,
229234
// try to find the unique not-the-same neighbour method in the same class:
230-
val neighbors = cls.methods
231-
.asSequence()
232-
.filter { it.name == callee.name }
235+
val neighbors = classMethodsByName[cls.signature].orEmpty()[callee.name].orEmpty()
233236
.filterNot { it.name == node.method.name }
234-
.toList()
235237
if (neighbors.isNotEmpty()) {
236238
val s = neighbors.singleOrNull()
237239
?: error("Multiple methods with the same name: $neighbors")

0 commit comments

Comments
 (0)