From 271d2126c0787707dcf91854986d6c4fc9f3b8a2 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 11 Aug 2019 14:17:41 +0100 Subject: [PATCH] Use InsnList's iterator instead of getFirst()/getNext() --- asm/src/main/java/dev/openrs2/asm/InsnMatcher.java | 3 ++- .../java/dev/openrs2/deob/transform/CounterTransformer.java | 3 ++- .../java/dev/openrs2/deob/transform/FieldOrderTransformer.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java b/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java index 65d4c06b05..c12b49c2fe 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java +++ b/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java @@ -216,7 +216,8 @@ public final class InsnMatcher { private static List createRealInsnList(InsnList list) { List realInsns = new ArrayList<>(); - for (var insn = list.getFirst(); insn != null; insn = insn.getNext()) { + for (var it = list.iterator(); it.hasNext(); ) { + var insn = it.next(); if (insn.getOpcode() != -1) { realInsns.add(insn); } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java index 0c873cacef..38b3f99750 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java +++ b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java @@ -47,7 +47,8 @@ public final class CounterTransformer extends Transformer { } private void findCounters(MethodNode method, Map references, Map resets, Map increments) { - for (var insn = method.instructions.getFirst(); insn != null; insn = insn.getNext()) { + for (var it = method.instructions.iterator(); it.hasNext(); ) { + var insn = it.next(); if (insn.getType() != AbstractInsnNode.FIELD_INSN) { continue; } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.java b/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.java index 66e80be11c..fad5b410be 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.java +++ b/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.java @@ -20,7 +20,8 @@ public final class FieldOrderTransformer extends Transformer { var fields = new HashMap(); var index = 0; - for (var insn = ctor.instructions.getFirst(); insn != null; insn = insn.getNext()) { + for (var it = ctor.instructions.iterator(); it.hasNext(); ) { + var insn = it.next(); if (insn.getOpcode() != opcode) { continue; }