You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we pass around EncodingRef to represent an encoding. It's type-defed to be a &'static dyn Encoding.
Most of our encodings are zero-sized structs, so this is pretty trivial to create. There are also a relatively small number of builtin encodings.
However, with #886 we added an OpaqueEncoding. This one actually is not zero-sized, but takes a u16 to keep track of the (unknown) encoding ID that it wraps. Instances are dynamically created in response to unknown encodings encountered in deserialization, and currently to keep with EncodingRef, we need to Box::leak to get the static reference.
There are a few alternatives
Make Context carry around a set of opaque_encodings. Care would need to be taken to make sure this collection is safe for concurrent updates
Change EncodingRef to be an Arc<dyn Encoding>. This will create an allocation for the builtin encodings whereas now there are none. However, there are only 25 builtin encodings, not that much to be allocating.
The text was updated successfully, but these errors were encountered:
Currently we pass around
EncodingRef
to represent an encoding. It's type-defed to be a&'static dyn Encoding
.Most of our encodings are zero-sized structs, so this is pretty trivial to create. There are also a relatively small number of builtin encodings.
However, with #886 we added an
OpaqueEncoding
. This one actually is not zero-sized, but takes au16
to keep track of the (unknown) encoding ID that it wraps. Instances are dynamically created in response to unknown encodings encountered in deserialization, and currently to keep withEncodingRef
, we need toBox::leak
to get the static reference.There are a few alternatives
Context
carry around a set ofopaque_encodings
. Care would need to be taken to make sure this collection is safe for concurrent updatesArc<dyn Encoding>
. This will create an allocation for the builtin encodings whereas now there are none. However, there are only 25 builtin encodings, not that much to be allocating.The text was updated successfully, but these errors were encountered: