optimized for jar size.

This commit is contained in:
wenshao
2017-01-14 20:37:12 +08:00
parent 6ed9c889e4
commit ed0adbe5fc
2 changed files with 5 additions and 4 deletions
@@ -487,7 +487,7 @@ public class JavaBeanSerializer implements ObjectSerializer {
if (fieldClass == int.class) {
// serializer.out.writeInt(propertyValueInt);
{
if (propertyValueInt == Integer.MIN_VALUE) {
if (propertyValueInt == 0x80000000 /*Integer.MIN_VALUE*/) {
out.write("-2147483648");
} else {
int size;
@@ -498,6 +498,7 @@ public class JavaBeanSerializer implements ObjectSerializer {
break;
}
}
if (propertyValueInt < 0) {
size++;
}
@@ -290,7 +290,7 @@ public final class SerializeWriter extends Writer {
}
public void writeInt(int i) {
if (i == Integer.MIN_VALUE) {
if (i == 0x80000000 /* Integer.MIN_VALUE*/) {
write("-2147483648");
return;
}
@@ -1117,7 +1117,7 @@ public final class SerializeWriter extends Writer {
}
}
final static int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE };
final static int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 0x7fffffff /*Integer.MAX_VALUE*/ };
protected static void getChars(long i, int index, char[] buf) {
long q;
@@ -1131,7 +1131,7 @@ public final class SerializeWriter extends Writer {
}
// Get 2 digits/iteration using longs until quotient fits into an int
while (i > Integer.MAX_VALUE) {
while (i > 0x7fffffff /* Integer.MAX_VALUE */ ) {
q = i / 100;
// really: r = i - (q * 100);
r = (int) (i - ((q << 6) + (q << 5) + (q << 2)));