Author: krasnov
Date: 2007-06-24 05:06:39 -0400 (Sun, 24 Jun 2007)
New Revision: 80615

Modified:
   trunk/mcs/class/System.Web/System.Web.Security/ChangeLog
   trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
Log:
* FormsAuthentication.cs: improved performance of GetHexString()


Modified: trunk/mcs/class/System.Web/System.Web.Security/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/ChangeLog    2007-06-24 
08:16:33 UTC (rev 80614)
+++ trunk/mcs/class/System.Web/System.Web.Security/ChangeLog    2007-06-24 
09:06:39 UTC (rev 80615)
@@ -1,3 +1,7 @@
+2007-06-24 Vladimir Krasnov <[EMAIL PROTECTED]>
+
+       * FormsAuthentication.cs: improved performance of GetHexString()
+
 2007-05-17 Vladimir Krasnov <[EMAIL PROTECTED]>
 
        * SqlMembershipProvider.cs: fixed DeleteUser, fixed parameter name

Modified: trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs       
2007-06-24 08:16:33 UTC (rev 80614)
+++ trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs       
2007-06-24 09:06:39 UTC (rev 80615)
@@ -462,11 +462,17 @@
 
                static string GetHexString (byte [] bytes)
                {
-                       StringBuilder result = new StringBuilder (bytes.Length 
* 2);
-                       foreach (byte b in bytes)
-                               result.AppendFormat ("{0:X2}", (int) b);
-
-                       return result.ToString ();
+                       const int letterPart = 55;
+                       const int numberPart = 48;
+                       char [] result = new char [bytes.Length * 2];
+                       for (int i = 0; i < bytes.Length; i++) {
+                               int tmp = (int) bytes [i];
+                               int second = tmp & 15;
+                               int first = (tmp >> 4) & 15;
+                               result [(i * 2)] = (char) (first > 9 ? 
letterPart + first : numberPart + first);
+                               result [(i * 2) + 1] = (char) (second > 9 ? 
letterPart + second : numberPart + second);
+                       }
+                       return new string (result);
                }
 
                public static string HashPasswordForStoringInConfigFile (string 
password, string passwordFormat)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to