Skip to content

Commit a702363

Browse files
author
Elad Zelingher
committed
Avoid boxing for WampMessageType key
1 parent f4c73e0 commit a702363

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/net45/WampSharp/Core/Dispatch/Handler/WampRequestMapper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ private Dictionary<WampMessageType, ICollection<WampMethodInfo>> BuildMapping(Ty
7575
.Where(x => x.Attribute != null);
7676

7777
var result =
78-
new Dictionary<WampMessageType, ICollection<WampMethodInfo>>();
78+
new Dictionary<WampMessageType, ICollection<WampMethodInfo>>
79+
(new WampMessageTypeComparer());
7980

8081
foreach (var relevantMethod in relevantMethods)
8182
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Collections.Generic;
2+
3+
namespace WampSharp.Core.Message
4+
{
5+
internal class WampMessageTypeComparer : IEqualityComparer<WampMessageType>
6+
{
7+
public bool Equals(WampMessageType x, WampMessageType y)
8+
{
9+
return x == y;
10+
}
11+
12+
public int GetHashCode(WampMessageType obj)
13+
{
14+
return (int) obj;
15+
}
16+
}
17+
}

src/net45/WampSharp/WampSharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<Compile Include="Core\Message\MessageType\MessageDirection.cs" />
120120
<Compile Include="Core\Message\MessageType\MessageTypeDetailsAttribute.cs" />
121121
<Compile Include="Core\Message\MessageType\WampMessageType.cs" />
122+
<Compile Include="Core\Message\MessageType\WampMessageTypeComparer.cs" />
122123
<Compile Include="Core\Message\WampMessage.cs" />
123124
<Compile Include="Core\Proxy\IWampOutgoingMessageHandler.cs" />
124125
<Compile Include="Core\Proxy\IWampOutgoingRequestSerializer.cs" />

0 commit comments

Comments
 (0)