@@ -38,12 +38,16 @@ import de.fraunhofer.aisec.cpg.graph.namespaces
38
38
import de.fraunhofer.aisec.cpg.graph.scopes.NameScope
39
39
import de.fraunhofer.aisec.cpg.graph.scopes.Scope
40
40
import de.fraunhofer.aisec.cpg.graph.translationUnit
41
+ import de.fraunhofer.aisec.cpg.helpers.IdentitySet
41
42
import de.fraunhofer.aisec.cpg.helpers.SubgraphWalker
42
43
import de.fraunhofer.aisec.cpg.helpers.Util.errorWithFileLocation
44
+ import de.fraunhofer.aisec.cpg.helpers.identitySetOf
45
+ import de.fraunhofer.aisec.cpg.helpers.toIdentitySet
43
46
import de.fraunhofer.aisec.cpg.passes.Pass.Companion.log
44
47
import de.fraunhofer.aisec.cpg.processing.strategy.Strategy
45
48
import de.fraunhofer.aisec.cpg.processing.strategy.Strategy.COMPONENTS_LEAST_IMPORTS
46
49
import de.fraunhofer.aisec.cpg.processing.strategy.Strategy.TRANSLATION_UNITS_LEAST_IMPORTS
50
+ import java.util.IdentityHashMap
47
51
48
52
/* *
49
53
* This class holds the information about import dependencies between nodes that represent some kind
@@ -53,12 +57,12 @@ import de.fraunhofer.aisec.cpg.processing.strategy.Strategy.TRANSLATION_UNITS_LE
53
57
* symbols and imports ideally. This is stored in [sorted] and is automatically computed the fist
54
58
* time someone accesses the property.
55
59
*/
56
- class ImportDependencies <T : Node >(modules : MutableList <T >) : HashMap <T, MutableSet <T>>() {
60
+ class ImportDependencies <T : Node >(modules : MutableList <T >) : IdentityHashMap <T, IdentitySet <T>>() {
57
61
58
62
init {
59
63
// Populate the map with all modules so that we have an entry in our list
60
64
// for all
61
- this + = modules.map { Pair (it, mutableSetOf ()) }
65
+ this + = modules.map { Pair (it, identitySetOf ()) }
62
66
}
63
67
64
68
/* *
@@ -70,7 +74,7 @@ class ImportDependencies<T : Node>(modules: MutableList<T>) : HashMap<T, Mutable
70
74
71
75
/* * Adds a dependency from [importer] to [imported]. */
72
76
fun add (importer : T , imported : T ): Boolean {
73
- var list = this .computeIfAbsent(importer) { mutableSetOf <T >() }
77
+ var list = this .computeIfAbsent(importer) { identitySetOf <T >() }
74
78
var added = list.add(imported)
75
79
76
80
return added
@@ -80,11 +84,11 @@ class ImportDependencies<T : Node>(modules: MutableList<T>) : HashMap<T, Mutable
80
84
* A work-list, which contains a local copy of our dependency map, so that we can remove items
81
85
* from it while determining the order.
82
86
*/
83
- class WorkList <T : Node >(start : ImportDependencies <T >) : HashMap <T, MutableSet <T>>() {
87
+ class WorkList <T : Node >(start : ImportDependencies <T >) : IdentityHashMap <T, IdentitySet <T>>() {
84
88
85
89
init {
86
90
// Populate the work-list with a copy of the import dependency map
87
- this + = start.map { Pair (it.key, it.value.toMutableSet ()) }
91
+ this + = start.map { Pair (it.key, it.value.toIdentitySet ()) }
88
92
}
89
93
90
94
/* *
0 commit comments