Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void WriteCompressed(uint value)
- {
- if (value <= 240)
- {
- Write((byte)value);
- return;
- }
- if (value <= 2287)
- {
- Write((byte)((value - 240) / 256 + 241));
- Write((byte)((value - 240) % 256));
- return;
- }
- if (value <= 67823)
- {
- Write((byte)249);
- Write((byte)((value - 2288) / 256));
- Write((byte)((value - 2288) % 256));
- return;
- }
- if (value <= 16777215)
- {
- Write((byte)250);
- Write((byte)(value & 0xFF));
- Write((byte)((value >> 8) & 0xFF));
- Write((byte)((value >> 16) & 0xFF));
- return;
- }
- Write((byte)251);
- Write((byte)(value & 0xFF));
- Write((byte)((value >> 8) & 0xFF));
- Write((byte)((value >> 16) & 0xFF));
- Write((byte)((value >> 24) & 0xFF));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement