-
New Feature
-
Resolution: Fixed
-
Minor
-
None
-
None
This removes the unpredictable branch in the NibbleArray. Since those two functions are used pretty often this branch costs pretty much.
It also reduces method code size to ease inlining.
public int a(int i) { int j = this.c(i); // Changes start int shift = shift(i); int aval = this.a[j]; return (aval >> shift) & 15; // Changes end } public void a(int i, int j) { int k = this.c(i); // Changes start int shift = shift(i); int aval = this.a[k]; aval &= ~(15<<shift); aval |= (j & 15) << shift; this.a[k] = (byte) aval; // Note: Using long[] would increase performance even more. // Changes end } // Changes start private int shift(int i) { return (i & 1) >> 2; } // Changes end