http-types icon indicating copy to clipboard operation
http-types copied to clipboard

WIP HeaderValue: make Cow<'static, str>

Open Fishrock123 opened this issue 4 years ago • 2 comments

This allows HeaderValue to borrow 'static strings, rather than make allocations.

Unfortunately, we can't specialize TryFrom or From, so this also adds a new crate-only from_static_str() -> HeaderValue.

Fishrock123 avatar Feb 12 '21 16:02 Fishrock123

Most header names (and many header values) will be short; we might want to use something like kstring here, with a small-string optimization. kstring also supports Cow.

joshtriplett avatar Jun 20 '22 19:06 joshtriplett

Most header names (and many header values) will be short; we might want to use something like kstring here, with a small-string optimization. kstring also supports Cow.

trillium's header name implementation does something like this, using smartcow which is just a cow for smartstring. However it might also make sense to use some sort of string interning library because there are only a handful of header names used in reality and they're repeated across requests

jbr avatar Jun 20 '22 23:06 jbr