Skip to content

Commit

Permalink
remove redundant null check in ComputeStringHash (#4420)
Browse files Browse the repository at this point in the history
Co-authored-by: Amaury Levé <[email protected]>
  • Loading branch information
SimonCropp and Evangelink authored Dec 29, 2024
1 parent 351f9ff commit 549f7d9
Showing 1 changed file with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ internal static class FNV_1aHashHelper
/// Computes a hash of the string using the FNV-1a algorithm.
/// Used by Roslyn.
/// </summary>
public static uint ComputeStringHash(string s)
{
uint num = default;
if (s != null)
{
num = 2166136261u;
int num2 = 0;
while (num2 < s.Length)
{
num = (s[num2] ^ num) * 16777619;
num2++;
}
}

return num;
}
public static uint ComputeStringHash(string input) =>
input.Aggregate(2166136261u, (current, ch) => (ch ^ current) * 16777619);
}

0 comments on commit 549f7d9

Please sign in to comment.