-
Notifications
You must be signed in to change notification settings - Fork 588
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
Gábor Zavarkó
committed
May 18, 2023
1 parent
8602332
commit a5ed6cd
Showing
6 changed files
with
93 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
52 changes: 43 additions & 9 deletions
52
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; | ||
|
||
internal 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 | ||
} | ||
} |