You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/08/21 20:21:22 UTC
svn commit: r1697036 -
/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java
Author: sebb
Date: Fri Aug 21 18:21:21 2015
New Revision: 1697036
URL: http://svn.apache.org/r1697036
Log:
Simplify: eliminate alias and use shared casting method instead
Modified:
commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java?rev=1697036&r1=1697035&r2=1697036&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java Fri Aug 21 18:21:21 2015
@@ -30,12 +30,8 @@ package org.apache.commons.bcel6.generic
*/
public final class BranchHandle extends InstructionHandle {
- private BranchInstruction bi; // An alias in fact, but saves lots of casts
-
-
private BranchHandle(BranchInstruction i) {
super(i);
- bi = i;
}
/** Factory methods.
@@ -62,6 +58,11 @@ public final class BranchHandle extends
bh_list = this;
}
+ // get the instruction as a BranchInstruction
+ // (do the cast once)
+ private BranchInstruction getBI() {
+ return (BranchInstruction) super.getInstruction();
+ }
/* Override InstructionHandle methods: delegate to branch instruction.
* Through this overriding all access to the private i_position field should
@@ -69,20 +70,20 @@ public final class BranchHandle extends
*/
@Override
public int getPosition() {
- return bi.getPosition();
+ return getBI().getPosition();
}
@Override
void setPosition( int pos ) {
- i_position = bi.setGetPosition(pos);
+ i_position = getBI().setGetPosition(pos);
}
@Override
protected int updatePosition( int offset, int max_offset ) {
- int x = bi.updatePosition(offset, max_offset);
- i_position = bi.getPosition();
+ int x = getBI().updatePosition(offset, max_offset);
+ i_position = getBI().getPosition();
return x;
}
@@ -91,7 +92,7 @@ public final class BranchHandle extends
* Pass new target to instruction.
*/
public void setTarget( InstructionHandle ih ) {
- bi.setTarget(ih);
+ getBI().setTarget(ih);
}
@@ -99,7 +100,7 @@ public final class BranchHandle extends
* Update target of instruction.
*/
public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) {
- bi.updateTarget(old_ih, new_ih);
+ getBI().updateTarget(old_ih, new_ih);
}
@@ -107,7 +108,7 @@ public final class BranchHandle extends
* @return target of instruction.
*/
public InstructionHandle getTarget() {
- return bi.getTarget();
+ return getBI().getTarget();
}
@@ -121,6 +122,5 @@ public final class BranchHandle extends
throw new ClassGenException("Assigning " + i
+ " to branch handle which is not a branch instruction");
}
- bi = (BranchInstruction) i;
}
}