Currently, the HeaderDescriptor struct has two fields:
private readonly string _headerName;
private readonly KnownHeader? _knownHeader;
A HeaderDescriptor is either:
(1) a known header, in which case KnownHeader is not null and _headerName is equal to _knownHeader.Name; or
(2) a custom header, in which case KnownHeader is null
We use HeaderDescriptor as the key for the HttpHeader header dictionary, which means we end up having a lot of instances of this structure.
We could optimize for memory here by combining these two fields into a single object field that contains either a string or a KnownHeader, and then do type casts. This would result in a small amount of additional CPU work to do the casts, but this may be worth the memory savings.
Currently, the HeaderDescriptor struct has two fields:
A HeaderDescriptor is either:
(1) a known header, in which case KnownHeader is not null and _headerName is equal to _knownHeader.Name; or
(2) a custom header, in which case KnownHeader is null
We use HeaderDescriptor as the key for the HttpHeader header dictionary, which means we end up having a lot of instances of this structure.
We could optimize for memory here by combining these two fields into a single object field that contains either a string or a KnownHeader, and then do type casts. This would result in a small amount of additional CPU work to do the casts, but this may be worth the memory savings.