Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove redundant null check in ComputeStringHash #4420

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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);
}
Loading