From 774744579d0453c5484777aabb8f82df00e5152a Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 29 May 2021 12:48:56 +0100 Subject: [PATCH] Replace LinkedHashSet queues with UniqueQueue Signed-off-by: Graham --- .../org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.kt | 6 +++--- .../deob/bytecode/transform/ConstantArgTransformer.kt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.kt b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.kt index 48b81dbe..87b5b480 100644 --- a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.kt +++ b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.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(owner: String, private val method: MethodNode, backwards: Boolean = false) { private val graph: Graph @@ -46,11 +46,11 @@ public abstract class DataFlowAnalyzer(owner: String, private val method: Met val entrySet = createEntrySet() val initialSet = createInitialSet() - val workList = LinkedHashSet() + val workList = UniqueQueue() 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 diff --git a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt index ce8b8eaa..70e6ea4b 100644 --- a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt +++ b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt @@ -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() + private val pendingMethods = UniqueQueue() private val arglessMethods = mutableSetOf>() private val argValues = mutableMapOf() private lateinit var inheritedMethodSets: DisjointSet @@ -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) } }