Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: combined hashcode conflict #77

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

Open
ikws4 wants to merge 1 commit into LibraStack:main
base: main
Choose a base branch
Loading
from ikws4:patch-1
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/UnityMvvmToolkit.Core/Internal/Helpers/HashCodeHelper.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityMvvmToolkit.Core.Interfaces;

namespace UnityMvvmToolkit.Core.Internal.Helpers
{
internal static class HashCodeHelper
{
private static Dictionary<(int, int), int> s_CombinedHashCodes = new Dictionary<(int, int), int>();
private static int s_StaticHashCodeId;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetMemberHashCode(Type contextType, string memberName)
{
Expand Down Expand Up @@ -88,11 +92,12 @@ public static int GetCommandWrapperId(Type contextType, Type targetType, string
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CombineHashCode(int hash1, int hash2)
{
var hash = 17;
hash = hash * 31 + hash1;
hash = hash * 31 + hash2;

return hash;
if (!s_CombinedHashCodes.TryGetValue((hash1, hash2), out var hashCode))
{
hashCode = s_StaticHashCodeId++;
s_CombinedHashCodes.Add((hash1, hash2), hashCode);
}
return hashCode;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -101,4 +106,4 @@ public static int CombineHashCode(int hash1, int hash2, int hash3)
return CombineHashCode(CombineHashCode(hash1, hash2), hash3);
}
}
}
}

AltStyle によって変換されたページ (->オリジナル) /