Replace LinkedHashSet queues with UniqueQueue

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 49e5781288
commit 774744579d
  1. 6
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.kt
  2. 6
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt

@ -5,7 +5,7 @@ import org.jgrapht.graph.DefaultEdge
import org.jgrapht.graph.EdgeReversedGraph
import org.objectweb.asm.tree.AbstractInsnNode
import org.objectweb.asm.tree.MethodNode
import org.openrs2.util.collect.removeFirstOrNull
import org.openrs2.util.collect.UniqueQueue
public abstract class DataFlowAnalyzer<T>(owner: String, private val method: MethodNode, backwards: Boolean = false) {
private val graph: Graph<Int, DefaultEdge>
@ -46,11 +46,11 @@ public abstract class DataFlowAnalyzer<T>(owner: String, private val method: Met
val entrySet = createEntrySet()
val initialSet = createInitialSet()
val workList = LinkedHashSet<Int>()
val workList = UniqueQueue<Int>()
workList += graph.vertexSet().filter { vertex -> graph.inDegreeOf(vertex) == 0 }
while (true) {
val node = workList.removeFirstOrNull() ?: break
val node = workList.poll() ?: break
val predecessors = graph.incomingEdgesOf(node).map { edge ->
outSets[graph.getEdgeSource(edge)] ?: initialSet

@ -46,13 +46,13 @@ import org.openrs2.deob.bytecode.analysis.IntValueSet
import org.openrs2.deob.bytecode.filter.ReflectedConstructorFilter
import org.openrs2.deob.bytecode.remap.MethodMappingGenerator
import org.openrs2.util.collect.DisjointSet
import org.openrs2.util.collect.removeFirstOrNull
import org.openrs2.util.collect.UniqueQueue
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
public class ConstantArgTransformer @Inject constructor(private val profile: Profile) : Transformer() {
private val pendingMethods = LinkedHashSet<MemberRef>()
private val pendingMethods = UniqueQueue<MemberRef>()
private val arglessMethods = mutableSetOf<DisjointSet.Partition<MemberRef>>()
private val argValues = mutableMapOf<ArgPartition, IntValueSet>()
private lateinit var inheritedMethodSets: DisjointSet<MemberRef>
@ -72,7 +72,7 @@ public class ConstantArgTransformer @Inject constructor(private val profile: Pro
queueEntryPoints(classPath)
while (true) {
val method = pendingMethods.removeFirstOrNull() ?: break
val method = pendingMethods.poll() ?: break
analyzeMethod(classPath, method)
}
}

Loading…
Cancel
Save