UriHelper.HexEscapeMultiByte is now using StringBuilder.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Fri, 25 Jul 2014 12:20:38 +0000 (13:20 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Fri, 25 Jul 2014 12:20:38 +0000 (13:20 +0100)
mcs/class/System/System/UriHelper.cs

index b7440832dde8e4fd27f26840329ea91236d54ab9..f553f489151ffc9676d3e73ee665f4eb2a8a9816 100644 (file)
@@ -95,12 +95,16 @@ namespace System {
                internal static string HexEscapeMultiByte (char character)
                {
                        const string hex_upper_chars = "0123456789ABCDEF";
-                       string ret = "";
+
+                       var sb = new StringBuilder ();
                        byte [] bytes = Encoding.UTF8.GetBytes (new [] {character});
-                       foreach (byte b in bytes)
-                               ret += "%" + hex_upper_chars [((b & 0xf0) >> 4)] + hex_upper_chars [((b & 0x0f))];
+                       foreach (byte b in bytes) {
+                               sb.Append ("%");
+                               sb.Append (hex_upper_chars [(b & 0xf0) >> 4]);
+                               sb.Append (hex_upper_chars [b & 0x0f]);
+                       }
 
-                       return ret;
+                       return sb.ToString ();
                }
 
                internal static bool SupportsQuery (string scheme)