From de2eb6594ed449a8738f25569888ce55cdf414c0 Mon Sep 17 00:00:00 2001 From: Eric Bruneton Date: Sat, 31 Mar 2018 15:02:47 +0200 Subject: [PATCH] Improve the code quality of TryCatchBlockSorter. --- .../asm/commons/TryCatchBlockSorter.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java index e47860da..2901a842 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java @@ -51,13 +51,13 @@ import org.objectweb.asm.tree.TryCatchBlockNode; public class TryCatchBlockSorter extends MethodNode { public TryCatchBlockSorter( - final MethodVisitor mv, + final MethodVisitor methodVisitor, final int access, final String name, - final String desc, + final String descriptor, final String signature, final String[] exceptions) { - this(Opcodes.ASM6, mv, access, name, desc, signature, exceptions); + this(Opcodes.ASM6, methodVisitor, access, name, descriptor, signature, exceptions); if (getClass() != TryCatchBlockSorter.class) { throw new IllegalStateException(); } @@ -65,36 +65,36 @@ public class TryCatchBlockSorter extends MethodNode { protected TryCatchBlockSorter( final int api, - final MethodVisitor mv, + final MethodVisitor methodVisitor, final int access, final String name, - final String desc, + final String descriptor, final String signature, final String[] exceptions) { - super(api, access, name, desc, signature, exceptions); - this.mv = mv; + super(api, access, name, descriptor, signature, exceptions); + this.mv = methodVisitor; } @Override public void visitEnd() { - // Compares TryCatchBlockNodes by the length of their "try" block. - Comparator comp = + // Sort the TryCatchBlockNode elements by the length of their "try" block. + Collections.sort( + tryCatchBlocks, new Comparator() { - public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) { - int len1 = blockLength(t1); - int len2 = blockLength(t2); - return len1 - len2; + public int compare( + final TryCatchBlockNode tryCatchBlockNode1, + final TryCatchBlockNode tryCatchBlockNode2) { + return blockLength(tryCatchBlockNode1) - blockLength(tryCatchBlockNode2); } - private int blockLength(TryCatchBlockNode block) { - int startidx = instructions.indexOf(block.start); - int endidx = instructions.indexOf(block.end); - return endidx - startidx; + private int blockLength(final TryCatchBlockNode tryCatchBlockNode) { + int startIndex = instructions.indexOf(tryCatchBlockNode.start); + int endIndex = instructions.indexOf(tryCatchBlockNode.end); + return endIndex - startIndex; } - }; - Collections.sort(tryCatchBlocks, comp); - // Updates the 'target' of each try catch block annotation. + }); + // Update the 'target' of each try catch block annotation. for (int i = 0; i < tryCatchBlocks.size(); ++i) { tryCatchBlocks.get(i).updateIndex(i); } -- GitLab