diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c6c29113..5b930020 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -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);