Moved string array to class-level

Moved string array for file size units to a class-level const string
array for performance.
This commit is contained in:
yankejustin 2015-05-21 12:14:41 -04:00
parent 8b20dee5e1
commit 21261270d8
1 changed files with 1 additions and 1 deletions

View File

@ -9,6 +9,7 @@ namespace xServer.Core.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 @@ namespace xServer.Core.Helper
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)