Simplify calculateBodyLength
@@ -59,24 +59,16 @@ else if (in instanceof FileInputStream)
static int calculateBodyLength(
int length)
{
- int count = 1;
-
- if (length > 127)
- {
- int size = 1;
- int val = length;
-
- while ((val >>>= 8) != 0)
+ if (length < 128)
{
- size++;
+ return 1;
}
- for (int i = (size - 1) * 8; i >= 0; i -= 8)
+ int count = 2;
+ while ((length >>>= 8) != 0)
{
- count++;
+ ++count;
}
- }
-
return count;
}
