HashUtil.cs 679 B

12345678910111213141516171819202122232425262728
  1. using dnlib.DotNet;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace HybridCLR.Editor
  8. {
  9. public static class HashUtil
  10. {
  11. public static int CombineHash(int hash1, int hash2)
  12. {
  13. return hash1 * 1566083941 + hash2;
  14. }
  15. public static int ComputHash(List<TypeSig> sigs)
  16. {
  17. int hash = 135781321;
  18. TypeEqualityComparer tc = TypeEqualityComparer.Instance;
  19. foreach (var sig in sigs)
  20. {
  21. hash = hash * 1566083941 + tc.GetHashCode(sig);
  22. }
  23. return hash;
  24. }
  25. }
  26. }