DirtyUtils.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Runtime.CompilerServices;
  2. namespace Asset_Cleaner {
  3. static class DirtyUtils {
  4. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  5. public static int HashCode<T1>(in T1 v1) {
  6. var hash = v1.GetHashCode();
  7. hash = (hash * 397);
  8. return hash;
  9. }
  10. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  11. public static int HashCode<T1, T2>(in T1 v1, in T2 v2) {
  12. var hash = v1.GetHashCode();
  13. hash = (hash * 397) ^ v2.GetHashCode();
  14. return hash;
  15. }
  16. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  17. public static int HashCode<T1, T2, T3>(in T1 v1, in T2 v2, in T3 v3) {
  18. var hash = v1.GetHashCode();
  19. hash = (hash * 397) ^ v2.GetHashCode();
  20. hash = (hash * 397) ^ v3.GetHashCode();
  21. return hash;
  22. }
  23. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  24. public static int HashCode<T1, T2, T3, T4>(in T1 v1, in T2 v2, in T3 v3, in T4 v4) {
  25. var hash = v1.GetHashCode();
  26. hash = (hash * 397) ^ v2.GetHashCode();
  27. hash = (hash * 397) ^ v3.GetHashCode();
  28. hash = (hash * 397) ^ v4.GetHashCode();
  29. return hash;
  30. }
  31. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  32. public static int HashCode<T1, T2, T3, T4, T5>(in T1 v1, in T2 v2, in T3 v3, in T4 v4, in T5 v5) {
  33. var hash = v1.GetHashCode();
  34. hash = (hash * 397) ^ v2.GetHashCode();
  35. hash = (hash * 397) ^ v3.GetHashCode();
  36. hash = (hash * 397) ^ v4.GetHashCode();
  37. hash = (hash * 397) ^ v5.GetHashCode();
  38. return hash;
  39. }
  40. }
  41. }