From babc702f10b3c844d0c58e20434954e361677356 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jul 2019 21:02:24 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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)