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:
parent
4f54570dbf
commit
f08ed7d976
1 changed files with 7 additions and 2 deletions
|
@ -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)
|
||||
code.AppendF($"\t\thash = Mix(hash, val{tupleMemberIdx});\n");
|
||||
{
|
||||
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++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue