From a26efcb30c003f826191749c4c68c92ec1d94e6d Mon Sep 17 00:00:00 2001 From: Graham Date: Mon, 30 Sep 2019 14:49:37 +0100 Subject: [PATCH] Use for-each to iterate over InsnLists --- asm/src/main/java/dev/openrs2/asm/InsnMatcher.java | 3 +-- asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.java | 3 +-- .../dev/openrs2/bundler/transform/CachePathTransformer.java | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java b/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java index 3767761c5e..5876133d10 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java +++ b/asm/src/main/java/dev/openrs2/asm/InsnMatcher.java @@ -225,8 +225,7 @@ public final class InsnMatcher { private static List createRealInsnList(InsnList list) { List realInsns = new ArrayList<>(); - for (var it = list.iterator(); it.hasNext(); ) { - var insn = it.next(); + for (var insn : list) { if (insn.getOpcode() != -1) { realInsns.add(insn); } diff --git a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.java b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.java index e42d4b3073..771d4f6273 100644 --- a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.java +++ b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.java @@ -109,8 +109,7 @@ public final class MethodNodeUtils { method.invisibleLocalVariableAnnotations.forEach(v -> v.index = remapAll(v.index, argType, localIndex)); } - for (var it = method.instructions.iterator(); it.hasNext(); ) { - var insn = it.next(); + for (var insn : method.instructions) { switch (insn.getType()) { case AbstractInsnNode.VAR_INSN: var varInsn = (VarInsnNode) insn; diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.java b/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.java index b9a5a72b35..aab5de9591 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.java +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.java @@ -22,8 +22,7 @@ public final class CachePathTransformer extends Transformer { @Override protected boolean transformCode(ClassPath classPath, Library library, ClassNode clazz, MethodNode method) { - for (var it = method.instructions.iterator(); it.hasNext(); ) { - var insn = it.next(); + for (var insn : method.instructions) { if (insn.getOpcode() != Opcodes.LDC) { continue; }