mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
Fun fact: it's never worth writing a length as an int8.
This commit is contained in:
@@ -125,12 +125,10 @@ class WriterImpl implements Writer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeLength(int i) throws IOException {
|
private void writeLength(int i) throws IOException {
|
||||||
if(i >= 0 && i <= Byte.MAX_VALUE)
|
assert i >= 0;
|
||||||
writeUint7((byte) i);
|
// Fun fact: it's never worth writing a length as an int8
|
||||||
else if(i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE)
|
if(i <= Byte.MAX_VALUE) writeUint7((byte) i);
|
||||||
writeInt8((byte) i);
|
else if(i <= Short.MAX_VALUE) writeInt16((short) i);
|
||||||
else if(i >= Short.MIN_VALUE && i <= Short.MAX_VALUE)
|
|
||||||
writeInt16((short) i);
|
|
||||||
else writeInt32(i);
|
else writeInt32(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user