optimize actix-http messages
@@ -343,6 +343,8 @@ impl ResponseHead {
}
pub struct Message<T: Head> {
+ // Rc here should not be cloned by anyone.
+ // It's used to reuse allocation of T and no shared ownership is allowed.
head: Rc<T>,
}
@@ -353,14 +355,6 @@ impl<T: Head> Message<T> {
}
}
-impl<T: Head> Clone for Message<T> {
- fn clone(&self) -> Self {
- Message {
- head: self.head.clone(),
- }
- }
-}
-
impl<T: Head> std::ops::Deref for Message<T> {
type Target = T;
@@ -377,11 +371,9 @@ impl<T: Head> std::ops::DerefMut for Message<T> {
impl<T: Head> Drop for Message<T> {
fn drop(&mut self) {
- if Rc::strong_count(&self.head) == 1 {
T::with_pool(|p| p.release(self.head.clone()))
}
}
-}
pub(crate) struct BoxedResponseHead {
head: Option<Box<ResponseHead>>,
