1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

HashCode optimization for enums with payloads

This commit is contained in:
Brian Fiete 2023-11-18 07:58:39 -05:00
parent 4f54570dbf
commit f08ed7d976

View file

@ -53,9 +53,14 @@ static class HashCode
code.Append(":\n");
if (enumCaseCount > 0)
code.AppendF($"\t\thash = Mix(hash, {enumCaseCount});\n");
code.AppendF($"\t\thash = {enumCaseCount};\n");
for (int tupleMemberIdx < tupleMemberCount)
{
if ((enumCaseCount == 0) && (tupleMemberIdx == 0))
code.AppendF($"\t\thash = SelfOuter.Get(val{tupleMemberIdx});\n");
else
code.AppendF($"\t\thash = Mix(hash, val{tupleMemberIdx});\n");
}
enumCaseCount++;
}