forked from rabbitmq/rabbitmq-dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not create consumerTag string in HandleBasicDeliver when conumer e…
…xists in the dictionary
- Loading branch information
zavarkog
committed
Jun 25, 2022
1 parent
926b2f8
commit fc636a2
Showing
6 changed files
with
94 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 44 additions & 9 deletions
53
projects/RabbitMQ.Client/client/impl/ConsumerDispatching/ConsumerDispatcherBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
projects/RabbitMQ.Client/util/MemoryOfByteEqualityComparer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace RabbitMQ.Util; | ||
|
||
public sealed class MemoryOfByteEqualityComparer : IEqualityComparer<ReadOnlyMemory<byte>> | ||
{ | ||
public static MemoryOfByteEqualityComparer Instance { get; } = new MemoryOfByteEqualityComparer(); | ||
|
||
public bool Equals(ReadOnlyMemory<byte> left, ReadOnlyMemory<byte> right) | ||
{ | ||
return left.Span.SequenceEqual(right.Span); | ||
} | ||
|
||
public int GetHashCode(ReadOnlyMemory<byte> value) | ||
{ | ||
#if NETSTANDARD | ||
unchecked | ||
{ | ||
int hashCode = 0; | ||
var longPart = MemoryMarshal.Cast<byte, long>(value.Span); | ||
foreach (long item in longPart) | ||
{ | ||
hashCode = (hashCode * 397) ^ item.GetHashCode(); | ||
} | ||
|
||
foreach (int item in value.Span.Slice(longPart.Length * 8)) | ||
{ | ||
hashCode = (hashCode * 397) ^ item.GetHashCode(); | ||
} | ||
|
||
return hashCode; | ||
} | ||
#else | ||
HashCode result = default; | ||
result.AddBytes(value.Span); | ||
return result.ToHashCode(); | ||
#endif | ||
} | ||
} |