smithy-rs
smithy-rs copied to clipboard
More efficient mime type parsing in server SDKs; avoid `mime` crate
We're currently creating one OnceCell
per operation backing a static mime::Mime
type for the operation's expected (if present) client Accept
header value, only to then decompose it into type + subtype and perform a case-insensitive string comparison check against the actual incoming Accept
header value.
It would be more efficient to directly compare &str
s and avoid incurring the atomic read.
A simpler, more efficient, and type-safe approach would be to directly switch to something like mediatype
, which is const-constructible and zero-copy. Note that mime
is not actively maintained.
See https://github.com/awslabs/smithy-rs/pull/2607#discussion_r1173687692 and https://github.com/awslabs/smithy-rs/pull/2629, the PR where we started using OnceCell
s for this.