From 21261270d8165412b3f173f7e9ed26a4e2661ab9 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Thu, 21 May 2015 12:14:41 -0400 Subject: [PATCH] Moved string array to class-level Moved string array for file size units to a class-level const string array for performance. --- Server/Core/Helper/Helper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/Core/Helper/Helper.cs b/Server/Core/Helper/Helper.cs index 2f0e1751..d37fbbb8 100644 --- a/Server/Core/Helper/Helper.cs +++ b/Server/Core/Helper/Helper.cs @@ -9,6 +9,7 @@ public static class Helper { private const string CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private static readonly Random _rnd = new Random(Environment.TickCount); + private const string[] sizes = { "B", "KB", "MB", "GB" }; public static string GetRandomFilename(int length, string extension) { @@ -30,7 +31,6 @@ public static string GetRandomName(int length) public static string GetFileSize(long size) { - string[] sizes = {"B", "KB", "MB", "GB"}; double len = size; int order = 0; while (len >= 1024 && order + 1 < sizes.Length)