From: Ben Adams Date: Tue, 12 Dec 2017 05:26:22 +0000 (+0000) Subject: Make EventCacheKey IEquatable (#15470) X-Git-Tag: accepted/tizen/base/20180629.140029~357 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da74892128e6c35b12b43564f7bb0cb353b2b85b;p=platform%2Fupstream%2Fcoreclr.git Make EventCacheKey IEquatable (#15470) --- diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs index 684a9c0..1cdb855 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs @@ -351,7 +351,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // Key = (target object, event) // We use a key of object+event to save an extra dictionary // - internal struct EventCacheKey + internal struct EventCacheKey : IEquatable { internal object target; internal MethodInfo method; @@ -360,13 +360,10 @@ namespace System.Runtime.InteropServices.WindowsRuntime { return "(" + target + ", " + method + ")"; } - } - internal class EventCacheKeyEqualityComparer : IEqualityComparer - { - public bool Equals(EventCacheKey lhs, EventCacheKey rhs) + public bool Equals(EventCacheKey other) { - return (Object.Equals(lhs.target, rhs.target) && Object.Equals(lhs.method, rhs.method)); + return (Object.Equals(target, other.target) && Object.Equals(method, other.method)); } public int GetHashCode(EventCacheKey key) @@ -517,7 +514,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // them the latest token in this case. This is guaranteed by always giving the last token and always use equality to // add/remove event handlers internal volatile static Dictionary s_eventRegistrations = - new Dictionary(new EventCacheKeyEqualityComparer()); + new Dictionary(); // Prevent add/remove handler code to run at the same with with cache cleanup code private volatile static MyReaderWriterLock s_eventCacheRWLock = new MyReaderWriterLock();