Skip to content

Commit a418ee4

Browse files
Merge pull request #985 from stebet/stringImprovements
Speeding up shortstr/longstr (de)serialization.
2 parents 34aac15 + 5928eb9 commit a418ee4

30 files changed

+144
-91
lines changed

projects/RabbitMQ.Client/client/framing/BasicCancel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7070
public override int GetRequiredBufferSize()
7171
{
7272
int bufferSize = 1 + 1; // bytes for length of _consumerTag, bit fields
73-
bufferSize += Encoding.UTF8.GetByteCount(_consumerTag); // _consumerTag in bytes
73+
bufferSize += WireFormatting.GetByteCount(_consumerTag); // _consumerTag in bytes
7474
return bufferSize;
7575
}
7676
}

projects/RabbitMQ.Client/client/framing/BasicCancelOk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override int WriteArgumentsTo(Span<byte> span)
6666
public override int GetRequiredBufferSize()
6767
{
6868
int bufferSize = 1; // bytes for length of _consumerTag
69-
bufferSize += Encoding.UTF8.GetByteCount(_consumerTag); // _consumerTag in bytes
69+
bufferSize += WireFormatting.GetByteCount(_consumerTag); // _consumerTag in bytes
7070
return bufferSize;
7171
}
7272
}

projects/RabbitMQ.Client/client/framing/BasicConsume.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public override int WriteArgumentsTo(Span<byte> span)
9090
public override int GetRequiredBufferSize()
9191
{
9292
int bufferSize = 2 + 1 + 1 + 1; // bytes for _reserved1, length of _queue, length of _consumerTag, bit fields
93-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
94-
bufferSize += Encoding.UTF8.GetByteCount(_consumerTag); // _consumerTag in bytes
93+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
94+
bufferSize += WireFormatting.GetByteCount(_consumerTag); // _consumerTag in bytes
9595
bufferSize += WireFormatting.GetTableByteCount(_arguments); // _arguments in bytes
9696
return bufferSize;
9797
}

projects/RabbitMQ.Client/client/framing/BasicConsumeOk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override int WriteArgumentsTo(Span<byte> span)
6666
public override int GetRequiredBufferSize()
6767
{
6868
int bufferSize = 1; // bytes for length of _consumerTag
69-
bufferSize += Encoding.UTF8.GetByteCount(_consumerTag); // _consumerTag in bytes
69+
bufferSize += WireFormatting.GetByteCount(_consumerTag); // _consumerTag in bytes
7070
return bufferSize;
7171
}
7272
}

projects/RabbitMQ.Client/client/framing/BasicDeliver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public override int WriteArgumentsTo(Span<byte> span)
8383
public override int GetRequiredBufferSize()
8484
{
8585
int bufferSize = 1 + 8 + 1 + 1 + 1; // bytes for length of _consumerTag, _deliveryTag, bit fields, length of _exchange, length of _routingKey
86-
bufferSize += Encoding.UTF8.GetByteCount(_consumerTag); // _consumerTag in bytes
87-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
88-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
86+
bufferSize += WireFormatting.GetByteCount(_consumerTag); // _consumerTag in bytes
87+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
88+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
8989
return bufferSize;
9090
}
9191
}

projects/RabbitMQ.Client/client/framing/BasicGet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7474
public override int GetRequiredBufferSize()
7575
{
7676
int bufferSize = 2 + 1 + 1; // bytes for _reserved1, length of _queue, bit fields
77-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
77+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
7878
return bufferSize;
7979
}
8080
}

projects/RabbitMQ.Client/client/framing/BasicGetEmpty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override int WriteArgumentsTo(Span<byte> span)
6666
public override int GetRequiredBufferSize()
6767
{
6868
int bufferSize = 1; // bytes for length of _reserved1
69-
bufferSize += Encoding.UTF8.GetByteCount(_reserved1); // _reserved1 in bytes
69+
bufferSize += WireFormatting.GetByteCount(_reserved1); // _reserved1 in bytes
7070
return bufferSize;
7171
}
7272
}

projects/RabbitMQ.Client/client/framing/BasicGetOk.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public override int WriteArgumentsTo(Span<byte> span)
8282
public override int GetRequiredBufferSize()
8383
{
8484
int bufferSize = 8 + 1 + 1 + 1 + 4; // bytes for _deliveryTag, bit fields, length of _exchange, length of _routingKey, _messageCount
85-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
86-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
85+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
86+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
8787
return bufferSize;
8888
}
8989
}

projects/RabbitMQ.Client/client/framing/BasicProperties.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,20 @@ internal override int WritePropertiesTo(Span<byte> span)
260260
public override int GetRequiredPayloadBufferSize()
261261
{
262262
int bufferSize = 2; // number of presence fields (14) in 2 bytes blocks
263-
if (IsContentTypePresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_contentType); } // _contentType in bytes
264-
if (IsContentEncodingPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_contentEncoding); } // _contentEncoding in bytes
263+
if (IsContentTypePresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_contentType); } // _contentType in bytes
264+
if (IsContentEncodingPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_contentEncoding); } // _contentEncoding in bytes
265265
if (IsHeadersPresent()) { bufferSize += WireFormatting.GetTableByteCount(_headers); } // _headers in bytes
266266
if (IsDeliveryModePresent()) { bufferSize++; } // _deliveryMode in bytes
267267
if (IsPriorityPresent()) { bufferSize++; } // _priority in bytes
268-
if (IsCorrelationIdPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_correlationId); } // _correlationId in bytes
269-
if (IsReplyToPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_replyTo); } // _replyTo in bytes
270-
if (IsExpirationPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_expiration); } // _expiration in bytes
271-
if (IsMessageIdPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_messageId); } // _messageId in bytes
268+
if (IsCorrelationIdPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_correlationId); } // _correlationId in bytes
269+
if (IsReplyToPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_replyTo); } // _replyTo in bytes
270+
if (IsExpirationPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_expiration); } // _expiration in bytes
271+
if (IsMessageIdPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_messageId); } // _messageId in bytes
272272
if (IsTimestampPresent()) { bufferSize += 8; } // _timestamp in bytes
273-
if (IsTypePresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_type); } // _type in bytes
274-
if (IsUserIdPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_userId); } // _userId in bytes
275-
if (IsAppIdPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_appId); } // _appId in bytes
276-
if (IsClusterIdPresent()) { bufferSize += 1 + Encoding.UTF8.GetByteCount(_clusterId); } // _clusterId in bytes
273+
if (IsTypePresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_type); } // _type in bytes
274+
if (IsUserIdPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_userId); } // _userId in bytes
275+
if (IsAppIdPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_appId); } // _appId in bytes
276+
if (IsClusterIdPresent()) { bufferSize += 1 + WireFormatting.GetByteCount(_clusterId); } // _clusterId in bytes
277277
return bufferSize;
278278
}
279279
}

projects/RabbitMQ.Client/client/framing/BasicPublish.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public override int WriteArgumentsTo(Span<byte> span)
8080
public override int GetRequiredBufferSize()
8181
{
8282
int bufferSize = 2 + 1 + 1 + 1; // bytes for _reserved1, length of _exchange, length of _routingKey, bit fields
83-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
84-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
83+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
84+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
8585
return bufferSize;
8686
}
8787
}

projects/RabbitMQ.Client/client/framing/BasicReturn.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public override int WriteArgumentsTo(Span<byte> span)
7878
public override int GetRequiredBufferSize()
7979
{
8080
int bufferSize = 2 + 1 + 1 + 1; // bytes for _replyCode, length of _replyText, length of _exchange, length of _routingKey
81-
bufferSize += Encoding.UTF8.GetByteCount(_replyText); // _replyText in bytes
82-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
83-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
81+
bufferSize += WireFormatting.GetByteCount(_replyText); // _replyText in bytes
82+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
83+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
8484
return bufferSize;
8585
}
8686
}

projects/RabbitMQ.Client/client/framing/ChannelClose.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7878
public override int GetRequiredBufferSize()
7979
{
8080
int bufferSize = 2 + 1 + 2 + 2; // bytes for _replyCode, length of _replyText, _classId, _methodId
81-
bufferSize += Encoding.UTF8.GetByteCount(_replyText); // _replyText in bytes
81+
bufferSize += WireFormatting.GetByteCount(_replyText); // _replyText in bytes
8282
return bufferSize;
8383
}
8484
}

projects/RabbitMQ.Client/client/framing/ChannelOpen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override int WriteArgumentsTo(Span<byte> span)
6666
public override int GetRequiredBufferSize()
6767
{
6868
int bufferSize = 1; // bytes for length of _reserved1
69-
bufferSize += Encoding.UTF8.GetByteCount(_reserved1); // _reserved1 in bytes
69+
bufferSize += WireFormatting.GetByteCount(_reserved1); // _reserved1 in bytes
7070
return bufferSize;
7171
}
7272
}

projects/RabbitMQ.Client/client/framing/ConnectionBlocked.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override int WriteArgumentsTo(Span<byte> span)
6666
public override int GetRequiredBufferSize()
6767
{
6868
int bufferSize = 1; // bytes for length of _reason
69-
bufferSize += Encoding.UTF8.GetByteCount(_reason); // _reason in bytes
69+
bufferSize += WireFormatting.GetByteCount(_reason); // _reason in bytes
7070
return bufferSize;
7171
}
7272
}

projects/RabbitMQ.Client/client/framing/ConnectionClose.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7878
public override int GetRequiredBufferSize()
7979
{
8080
int bufferSize = 2 + 1 + 2 + 2; // bytes for _replyCode, length of _replyText, _classId, _methodId
81-
bufferSize += Encoding.UTF8.GetByteCount(_replyText); // _replyText in bytes
81+
bufferSize += WireFormatting.GetByteCount(_replyText); // _replyText in bytes
8282
return bufferSize;
8383
}
8484
}

projects/RabbitMQ.Client/client/framing/ConnectionOpen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public override int WriteArgumentsTo(Span<byte> span)
7474
public override int GetRequiredBufferSize()
7575
{
7676
int bufferSize = 1 + 1 + 1; // bytes for length of _virtualHost, length of _reserved1, bit fields
77-
bufferSize += Encoding.UTF8.GetByteCount(_virtualHost); // _virtualHost in bytes
78-
bufferSize += Encoding.UTF8.GetByteCount(_reserved1); // _reserved1 in bytes
77+
bufferSize += WireFormatting.GetByteCount(_virtualHost); // _virtualHost in bytes
78+
bufferSize += WireFormatting.GetByteCount(_reserved1); // _reserved1 in bytes
7979
return bufferSize;
8080
}
8181
}

projects/RabbitMQ.Client/client/framing/ConnectionOpenOk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override int WriteArgumentsTo(Span<byte> span)
6666
public override int GetRequiredBufferSize()
6767
{
6868
int bufferSize = 1; // bytes for length of _reserved1
69-
bufferSize += Encoding.UTF8.GetByteCount(_reserved1); // _reserved1 in bytes
69+
bufferSize += WireFormatting.GetByteCount(_reserved1); // _reserved1 in bytes
7070
return bufferSize;
7171
}
7272
}

projects/RabbitMQ.Client/client/framing/ConnectionStartOk.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public override int GetRequiredBufferSize()
8181
{
8282
int bufferSize = 1 + 4 +1; // bytes for length of _mechanism, length of _response, length of _locale
8383
bufferSize += WireFormatting.GetTableByteCount(_clientProperties); // _clientProperties in bytes
84-
bufferSize += Encoding.UTF8.GetByteCount(_mechanism); // _mechanism in bytes
84+
bufferSize += WireFormatting.GetByteCount(_mechanism); // _mechanism in bytes
8585
bufferSize += _response.Length; // _response in bytes
86-
bufferSize += Encoding.UTF8.GetByteCount(_locale); // _locale in bytes
86+
bufferSize += WireFormatting.GetByteCount(_locale); // _locale in bytes
8787
return bufferSize;
8888
}
8989
}

projects/RabbitMQ.Client/client/framing/ConnectionUpdateSecret.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public override int GetRequiredBufferSize()
7171
{
7272
int bufferSize = 4 + 1; // bytes for length of _newSecret, length of _reason
7373
bufferSize += _newSecret.Length; // _newSecret in bytes
74-
bufferSize += Encoding.UTF8.GetByteCount(_reason); // _reason in bytes
74+
bufferSize += WireFormatting.GetByteCount(_reason); // _reason in bytes
7575
return bufferSize;
7676
}
7777
}

projects/RabbitMQ.Client/client/framing/ExchangeBind.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public override int WriteArgumentsTo(Span<byte> span)
8888
public override int GetRequiredBufferSize()
8989
{
9090
int bufferSize = 2 + 1 + 1 + 1 + 1; // bytes for _reserved1, length of _destination, length of _source, length of _routingKey, bit fields
91-
bufferSize += Encoding.UTF8.GetByteCount(_destination); // _destination in bytes
92-
bufferSize += Encoding.UTF8.GetByteCount(_source); // _source in bytes
93-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
91+
bufferSize += WireFormatting.GetByteCount(_destination); // _destination in bytes
92+
bufferSize += WireFormatting.GetByteCount(_source); // _source in bytes
93+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
9494
bufferSize += WireFormatting.GetTableByteCount(_arguments); // _arguments in bytes
9595
return bufferSize;
9696
}

projects/RabbitMQ.Client/client/framing/ExchangeDeclare.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public override int WriteArgumentsTo(Span<byte> span)
9292
public override int GetRequiredBufferSize()
9393
{
9494
int bufferSize = 2 + 1 + 1 + 1; // bytes for _reserved1, length of _exchange, length of _type, bit fields
95-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
96-
bufferSize += Encoding.UTF8.GetByteCount(_type); // _type in bytes
95+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
96+
bufferSize += WireFormatting.GetByteCount(_type); // _type in bytes
9797
bufferSize += WireFormatting.GetTableByteCount(_arguments); // _arguments in bytes
9898
return bufferSize;
9999
}

projects/RabbitMQ.Client/client/framing/ExchangeDelete.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7676
public override int GetRequiredBufferSize()
7777
{
7878
int bufferSize = 2 + 1 + 1; // bytes for _reserved1, length of _exchange, bit fields
79-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
79+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
8080
return bufferSize;
8181
}
8282
}

projects/RabbitMQ.Client/client/framing/ExchangeUnbind.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public override int WriteArgumentsTo(Span<byte> span)
8888
public override int GetRequiredBufferSize()
8989
{
9090
int bufferSize = 2 + 1 + 1 + 1 + 1; // bytes for _reserved1, length of _destination, length of _source, length of _routingKey, bit fields
91-
bufferSize += Encoding.UTF8.GetByteCount(_destination); // _destination in bytes
92-
bufferSize += Encoding.UTF8.GetByteCount(_source); // _source in bytes
93-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
91+
bufferSize += WireFormatting.GetByteCount(_destination); // _destination in bytes
92+
bufferSize += WireFormatting.GetByteCount(_source); // _source in bytes
93+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
9494
bufferSize += WireFormatting.GetTableByteCount(_arguments); // _arguments in bytes
9595
return bufferSize;
9696
}

projects/RabbitMQ.Client/client/framing/QueueBind.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public override int WriteArgumentsTo(Span<byte> span)
8888
public override int GetRequiredBufferSize()
8989
{
9090
int bufferSize = 2 + 1 + 1 + 1 + 1; // bytes for _reserved1, length of _queue, length of _exchange, length of _routingKey, bit fields
91-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
92-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
93-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
91+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
92+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
93+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
9494
bufferSize += WireFormatting.GetTableByteCount(_arguments); // _arguments in bytes
9595
return bufferSize;
9696
}

projects/RabbitMQ.Client/client/framing/QueueDeclare.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public override int WriteArgumentsTo(Span<byte> span)
8888
public override int GetRequiredBufferSize()
8989
{
9090
int bufferSize = 2 + 1 + 1; // bytes for _reserved1, length of _queue, bit fields
91-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
91+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
9292
bufferSize += WireFormatting.GetTableByteCount(_arguments); // _arguments in bytes
9393
return bufferSize;
9494
}

projects/RabbitMQ.Client/client/framing/QueueDeclareOk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7474
public override int GetRequiredBufferSize()
7575
{
7676
int bufferSize = 1 + 4 + 4; // bytes for length of _queue, _messageCount, _consumerCount
77-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
77+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
7878
return bufferSize;
7979
}
8080
}

projects/RabbitMQ.Client/client/framing/QueueDelete.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7878
public override int GetRequiredBufferSize()
7979
{
8080
int bufferSize = 2 + 1 + 1; // bytes for _reserved1, length of _queue, bit fields
81-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
81+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
8282
return bufferSize;
8383
}
8484
}

projects/RabbitMQ.Client/client/framing/QueuePurge.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public override int WriteArgumentsTo(Span<byte> span)
7474
public override int GetRequiredBufferSize()
7575
{
7676
int bufferSize = 2 + 1 + 1; // bytes for _reserved1, length of _queue, bit fields
77-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
77+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
7878
return bufferSize;
7979
}
8080
}

projects/RabbitMQ.Client/client/framing/QueueUnbind.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public override int WriteArgumentsTo(Span<byte> span)
8484
public override int GetRequiredBufferSize()
8585
{
8686
int bufferSize = 2 + 1 + 1 + 1; // bytes for _reserved1, length of _queue, length of _exchange, length of _routingKey
87-
bufferSize += Encoding.UTF8.GetByteCount(_queue); // _queue in bytes
88-
bufferSize += Encoding.UTF8.GetByteCount(_exchange); // _exchange in bytes
89-
bufferSize += Encoding.UTF8.GetByteCount(_routingKey); // _routingKey in bytes
87+
bufferSize += WireFormatting.GetByteCount(_queue); // _queue in bytes
88+
bufferSize += WireFormatting.GetByteCount(_exchange); // _exchange in bytes
89+
bufferSize += WireFormatting.GetByteCount(_routingKey); // _routingKey in bytes
9090
bufferSize += WireFormatting.GetTableByteCount(_arguments); // _arguments in bytes
9191
return bufferSize;
9292
}

0 commit comments

Comments
 (0)