From d2ad08d88a23c809d87420a6979d00c62af5eefc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 May 2015 15:42:51 +0900 Subject: [PATCH] Added internal EmptyByteArray field --- websocket-sharp/Ext.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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);