Added internal EmptyByteArray field

This commit is contained in:
sta 2015-05-19 15:42:51 +09:00
parent e58ee06c4b
commit d2ad08d88a

View File

@ -69,6 +69,12 @@ namespace WebSocketSharp
#endregion
#region Internal Fields
internal static readonly byte[] EmptyByteArray = new byte[0];
#endregion
#region Private Methods
private static byte[] compress (this byte[] data)
@ -670,13 +676,13 @@ namespace WebSocketSharp
try {
var len = stream.EndRead (ar);
bytes = len < 1
? new byte[0]
? EmptyByteArray
: len < length
? stream.readBytes (buff, len, length - len)
: buff;
}
catch {
bytes = new byte[0];
bytes = EmptyByteArray;
}
if (completed != null)
@ -1657,7 +1663,7 @@ namespace WebSocketSharp
? BitConverter.GetBytes ((UInt32)(object) value)
: type == typeof (UInt64)
? BitConverter.GetBytes ((UInt64)(object) value)
: new byte[0];
: EmptyByteArray;
if (bytes.Length > 1 && !order.IsHostOrder ())
Array.Reverse (bytes);