Skip to content

Commit a8ebfc3

Browse files
authored
perf: replace manual hex formatting with Convert.ToHexStringLower (#2453)
1 parent cb19026 commit a8ebfc3

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

‎src/Models/AvatarManager.cs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ private string GetEmailHash(string email)
224224
{
225225
var lowered = email.ToLower(CultureInfo.CurrentCulture).Trim();
226226
var hash = MD5.HashData(Encoding.Default.GetBytes(lowered));
227-
var builder = new StringBuilder(hash.Length * 2);
228-
foreach (var c in hash)
229-
builder.Append(c.ToString("x2"));
230-
return builder.ToString();
227+
return Convert.ToHexStringLower(hash);
231228
}
232229

233230
private void NotifyResourceChanged(string email, Bitmap image)

‎src/Models/RepositorySettings.cs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ public void MoveCustomActionDown(CustomAction act)
171171
private static string HashContent(string source)
172172
{
173173
var hash = MD5.HashData(Encoding.Default.GetBytes(source));
174-
var builder = new StringBuilder(hash.Length * 2);
175-
foreach (var c in hash)
176-
builder.Append(c.ToString("x2"));
177-
return builder.ToString();
174+
return Convert.ToHexStringLower(hash);
178175
}
179176

180177
private static Dictionary<string, RepositorySettings> _cache = new();

0 commit comments

Comments
 (0)