@@ -11,15 +11,16 @@ import io.shiftleft.proto.cpg.Cpg.CpgStruct.Node
1111import io .shiftleft .proto .cpg .Cpg .CpgStruct .Node .NodeType
1212import io .shiftleft .proto .cpg .Cpg .{CpgStruct , NodePropertyName }
1313import java .nio .file .{Files , Path }
14- import java .util .concurrent .LinkedBlockingQueue
14+ import java .util .concurrent .{ConcurrentHashMap , LinkedBlockingQueue }
15+
1516import io .shiftleft .passes .KeyPool
1617
17- import scala .collection .mutable
1818import scala .collection .mutable .ListBuffer
1919import scala .collection .parallel .CollectionConverters ._
2020import scala .util .control .NonFatal
21+ import scala .jdk .CollectionConverters ._
2122
22- case class Global (usedTypes : mutable. Set [String ] = new mutable. HashSet [String ] )
23+ case class Global (usedTypes : ConcurrentHashMap [String , Boolean ] = new ConcurrentHashMap [String , Boolean ]() )
2324
2425class FuzzyC2Cpg (outputModuleFactory : CpgOutputModuleFactory ) {
2526 import FuzzyC2Cpg .logger
@@ -119,7 +120,7 @@ class FuzzyC2Cpg(outputModuleFactory: CpgOutputModuleFactory) {
119120 }
120121 }
121122
122- private def addTypeNodes (usedTypes : mutable. Set [String ], keyPool : KeyPool ): Unit = {
123+ private def addTypeNodes (usedTypes : ConcurrentHashMap [String , Boolean ], keyPool : KeyPool ): Unit = {
123124 val cpg = CpgStruct .newBuilder()
124125 val outputModule = outputModuleFactory.create()
125126 outputModule.setOutputIdentifier(" __types__" )
@@ -158,8 +159,14 @@ class FuzzyC2Cpg(outputModuleFactory: CpgOutputModuleFactory) {
158159 .build
159160 }
160161
161- private def createTypeNodes (usedTypes : mutable.Set [String ], keyPool : KeyPool , cpg : CpgStruct .Builder ): Unit = {
162- usedTypes.toList.sorted
162+ private def createTypeNodes (usedTypes : ConcurrentHashMap [String , Boolean ],
163+ keyPool : KeyPool ,
164+ cpg : CpgStruct .Builder ): Unit = {
165+ usedTypes
166+ .keys()
167+ .asScala
168+ .toList
169+ .sorted
163170 .foreach { typeName =>
164171 val node = newNode(NodeType .TYPE )
165172 .setKey(keyPool.next)
0 commit comments