rabbitmq-dotnet-client icon indicating copy to clipboard operation
rabbitmq-dotnet-client copied to clipboard

BasicProperties.ReadPropertiesFrom tends to resize the headers dictionary

Open danielmarbach opened this issue 9 months ago • 0 comments

Is your feature request related to a problem? Please describe.

BasicProperties.ReadPropertiesFrom has quite a bit of allocations coming from resizing / growing the capacity of the properties dictionary.

image

I did have a first glance but it seems there is not a good way to determine the dictionary size needed as part of the WireFormatting.ReadDictionary because there we only get the header length as long which doesn't give as a hint about how many dictionary buckets we need.

Describe the solution you'd like

Ideally there would be a way to determine the number of buckets required to preallocate the capacity of the properties dictionary. THIS eliminates the need to perform a number of resizing operations while adding elements to the dictionary.

Describe alternatives you've considered

None

Additional context

None

danielmarbach avatar May 03 '24 22:05 danielmarbach