Removed unneeded & 0xFF ops
This commit is contained in:
@@ -441,10 +441,10 @@ namespace Discord.Net.WebSockets
|
||||
_sequence = 0;// (ushort)_rand.Next(0, ushort.MaxValue);
|
||||
//No thread issue here because SendAsync doesn't start until _isReady is true
|
||||
byte[] packet = new byte[70];
|
||||
packet[0] = (byte)((_ssrc >> 24) & 0xFF);
|
||||
packet[1] = (byte)((_ssrc >> 16) & 0xFF);
|
||||
packet[2] = (byte)((_ssrc >> 8) & 0xFF);
|
||||
packet[3] = (byte)((_ssrc >> 0) & 0xFF);
|
||||
packet[0] = (byte)(_ssrc >> 24);
|
||||
packet[1] = (byte)(_ssrc >> 16);
|
||||
packet[2] = (byte)(_ssrc >> 8);
|
||||
packet[3] = (byte)(_ssrc >> 0);
|
||||
await _udp.SendAsync(packet, 70).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ namespace Discord.ETF
|
||||
else
|
||||
_stream.Write(_falseBytes, 0, _falseBytes.Length);
|
||||
}
|
||||
|
||||
public void Write(sbyte value) => Write((long)value);
|
||||
public void Write(byte value) => Write((ulong)value);
|
||||
public void Write(short value) => Write((long)value);
|
||||
@@ -74,10 +73,10 @@ namespace Discord.ETF
|
||||
else if (value >= int.MinValue && value <= int.MaxValue)
|
||||
{
|
||||
_buffer[0] = (byte)ETFType.INTEGER_EXT;
|
||||
_buffer[1] = (byte)((value >> 24) & 0xFF);
|
||||
_buffer[2] = (byte)((value >> 16) & 0xFF);
|
||||
_buffer[3] = (byte)((value >> 8) & 0xFF);
|
||||
_buffer[4] = (byte)(value & 0xFF);
|
||||
_buffer[1] = (byte)(value >> 24);
|
||||
_buffer[2] = (byte)(value >> 16);
|
||||
_buffer[3] = (byte)(value >> 8);
|
||||
_buffer[4] = (byte)value;
|
||||
_stream.Write(_buffer, 0, 5);
|
||||
}
|
||||
else
|
||||
@@ -91,7 +90,7 @@ namespace Discord.ETF
|
||||
|
||||
byte bytes = 0;
|
||||
while (value > 0)
|
||||
_buffer[3 + bytes++] = (byte)((value >>= 8) & 0xFF);
|
||||
_buffer[3 + bytes++] = (byte)(value >>= 8);
|
||||
_buffer[1] = bytes; //Encoded bytes
|
||||
|
||||
_stream.Write(_buffer, 0, 3 + bytes);
|
||||
@@ -108,10 +107,10 @@ namespace Discord.ETF
|
||||
else if (value <= int.MaxValue)
|
||||
{
|
||||
_buffer[0] = (byte)ETFType.INTEGER_EXT;
|
||||
_buffer[1] = (byte)((value >> 24) & 0xFF);
|
||||
_buffer[2] = (byte)((value >> 16) & 0xFF);
|
||||
_buffer[3] = (byte)((value >> 8) & 0xFF);
|
||||
_buffer[4] = (byte)(value & 0xFF);
|
||||
_buffer[1] = (byte)(value >> 24);
|
||||
_buffer[2] = (byte)(value >> 16);
|
||||
_buffer[3] = (byte)(value >> 8);
|
||||
_buffer[4] = (byte)value;
|
||||
_stream.Write(_buffer, 0, 5);
|
||||
}
|
||||
else
|
||||
@@ -121,7 +120,7 @@ namespace Discord.ETF
|
||||
|
||||
byte bytes = 0;
|
||||
while (value > 0)
|
||||
_buffer[3 + bytes++] = (byte)((value >>= 8) & 0xFF);
|
||||
_buffer[3 + bytes++] = (byte)(value >>= 8);
|
||||
_buffer[1] = bytes; //Encoded bytes
|
||||
|
||||
_stream.Write(_buffer, 0, 3 + bytes);
|
||||
@@ -133,14 +132,14 @@ namespace Discord.ETF
|
||||
{
|
||||
ulong value2 = *(ulong*)&value;
|
||||
_buffer[0] = (byte)ETFType.NEW_FLOAT_EXT;
|
||||
_buffer[1] = (byte)((value2 >> 56) & 0xFF);
|
||||
_buffer[2] = (byte)((value2 >> 48) & 0xFF);
|
||||
_buffer[3] = (byte)((value2 >> 40) & 0xFF);
|
||||
_buffer[4] = (byte)((value2 >> 32) & 0xFF);
|
||||
_buffer[5] = (byte)((value2 >> 24) & 0xFF);
|
||||
_buffer[6] = (byte)((value2 >> 16) & 0xFF);
|
||||
_buffer[7] = (byte)((value2 >> 8) & 0xFF);
|
||||
_buffer[8] = (byte)(value2 & 0xFF);
|
||||
_buffer[1] = (byte)(value2 >> 56);
|
||||
_buffer[2] = (byte)(value2 >> 48);
|
||||
_buffer[3] = (byte)(value2 >> 40);
|
||||
_buffer[4] = (byte)(value2 >> 32);
|
||||
_buffer[5] = (byte)(value2 >> 24);
|
||||
_buffer[6] = (byte)(value2 >> 16);
|
||||
_buffer[7] = (byte)(value2 >> 8);
|
||||
_buffer[8] = (byte)value2;
|
||||
_stream.Write(_buffer, 0, 9);
|
||||
}
|
||||
|
||||
@@ -165,10 +164,10 @@ namespace Discord.ETF
|
||||
{
|
||||
int count = value.Length;
|
||||
_buffer[0] = (byte)ETFType.BINARY_EXT;
|
||||
_buffer[1] = (byte)((count >> 24) & 0xFF);
|
||||
_buffer[2] = (byte)((count >> 16) & 0xFF);
|
||||
_buffer[3] = (byte)((count >> 8) & 0xFF);
|
||||
_buffer[4] = (byte)(count & 0xFF);
|
||||
_buffer[1] = (byte)(count >> 24);
|
||||
_buffer[2] = (byte)(count >> 16);
|
||||
_buffer[3] = (byte)(count >> 8);
|
||||
_buffer[4] = (byte)count;
|
||||
_stream.Write(_buffer, 0, 5);
|
||||
_stream.Write(value, 0, value.Length);
|
||||
}
|
||||
@@ -182,10 +181,10 @@ namespace Discord.ETF
|
||||
var bytes = _encoding.GetBytes(value);
|
||||
int count = bytes.Length;
|
||||
_buffer[0] = (byte)ETFType.BINARY_EXT;
|
||||
_buffer[1] = (byte)((count >> 24) & 0xFF);
|
||||
_buffer[2] = (byte)((count >> 16) & 0xFF);
|
||||
_buffer[3] = (byte)((count >> 8) & 0xFF);
|
||||
_buffer[4] = (byte)(count & 0xFF);
|
||||
_buffer[1] = (byte)(count >> 24);
|
||||
_buffer[2] = (byte)(count >> 16);
|
||||
_buffer[3] = (byte)(count >> 8);
|
||||
_buffer[4] = (byte)count;
|
||||
_stream.Write(_buffer, 0, 5);
|
||||
_stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
@@ -215,10 +214,10 @@ namespace Discord.ETF
|
||||
var array = obj.ToArray();
|
||||
int length = array.Length;
|
||||
_buffer[0] = (byte)ETFType.LIST_EXT;
|
||||
_buffer[1] = (byte)((length >> 24) & 0xFF);
|
||||
_buffer[2] = (byte)((length >> 16) & 0xFF);
|
||||
_buffer[3] = (byte)((length >> 8) & 0xFF);
|
||||
_buffer[4] = (byte)(length & 0xFF);
|
||||
_buffer[1] = (byte)(length >> 24);
|
||||
_buffer[2] = (byte)(length >> 16);
|
||||
_buffer[3] = (byte)(length >> 8);
|
||||
_buffer[4] = (byte)length;
|
||||
_stream.Write(_buffer, 0, 5);
|
||||
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
@@ -236,10 +235,10 @@ namespace Discord.ETF
|
||||
{
|
||||
int length = obj.Count;
|
||||
_buffer[0] = (byte)ETFType.MAP_EXT;
|
||||
_buffer[1] = (byte)((length >> 24) & 0xFF);
|
||||
_buffer[2] = (byte)((length >> 16) & 0xFF);
|
||||
_buffer[3] = (byte)((length >> 8) & 0xFF);
|
||||
_buffer[4] = (byte)(length & 0xFF);
|
||||
_buffer[1] = (byte)(length >> 24);
|
||||
_buffer[2] = (byte)(length >> 16);
|
||||
_buffer[3] = (byte)(length >> 8);
|
||||
_buffer[4] = (byte)length;
|
||||
_stream.Write(_buffer, 0, 5);
|
||||
|
||||
foreach (var pair in obj)
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Discord
|
||||
//Bypasses isLocked for API changes.
|
||||
_rawValue = rawValue;
|
||||
}
|
||||
private byte GetByte(int pos) => (byte)((_rawValue >> (8 * (pos - 1))) & 0xFF);
|
||||
private byte GetByte(int pos) => (byte)(_rawValue >> (8 * (pos - 1)));
|
||||
private void SetByte(int pos, byte value)
|
||||
{
|
||||
if (_isLocked)
|
||||
@@ -75,7 +75,7 @@ namespace Discord
|
||||
|
||||
uint original = _rawValue;
|
||||
int bit = 8 * (pos - 1);
|
||||
uint mask = (uint)~(0xFF << bit);
|
||||
uint mask = ~(0xFFU << bit);
|
||||
_rawValue = (_rawValue & mask) | ((uint)value << bit);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user