diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 01a343d5..26c49eb0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -172,14 +172,15 @@ namespace WebSocketSharp internal static byte[] Append (this ushort code, string reason) { - var ret = code.InternalToByteArray (ByteOrder.Big); - if (reason != null && reason.Length > 0) { - var buff = new List (ret); - buff.AddRange (Encoding.UTF8.GetBytes (reason)); - ret = buff.ToArray (); - } + var bytes = code.InternalToByteArray (ByteOrder.Big); - return ret; + if (reason == null || reason.Length == 0) + return bytes; + + var buff = new List (bytes); + buff.AddRange (Encoding.UTF8.GetBytes (reason)); + + return buff.ToArray (); } internal static void Close (this HttpListenerResponse response, HttpStatusCode code)