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