philadelphia-core: Optimize 'FIXValue#setFloat'
This decreases the bytecode size of the method from 174 to 169 bytes.
@@ -399,32 +399,32 @@ public class FIXValue {
* @see #asFloat
*/
public void setFloat(double x, int decimals) {
- bytes[end - 1] = SOH;
+ int i = end;
- long y = Math.round(POWERS_OF_TEN[decimals] * Math.abs(x));
+ bytes[--i] = SOH;
- int i = end - 2;
+ long y = Math.round(POWERS_OF_TEN[decimals] * Math.abs(x));
for (int j = 0; j < decimals; j++) {
- bytes[i--] = (byte)('0' + y % 10);
+ bytes[--i] = (byte)('0' + y % 10);
y /= 10;
}
if (decimals > 0)
- bytes[i--] = '.';
+ bytes[--i] = '.';
do {
- bytes[i--] = (byte)('0' + y % 10);
+ bytes[--i] = (byte)('0' + y % 10);
y /= 10;
} while (y > 0);
if (x < 0)
- bytes[i--] = '-';
+ bytes[--i] = '-';
- offset = i + 1;
- length = end - 1 - offset;
+ offset = i;
+ length = end - offset - 1;
}
/**
