mirror of
https://github.com/actix/actix-web.git
synced 2024-11-29 13:01:09 +00:00
optimize actix-http messages (#1914)
This commit is contained in:
parent
4c243cbf89
commit
dbc47c9122
1 changed files with 3 additions and 11 deletions
|
@ -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,10 +371,8 @@ 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 {
|
||||
|
|
Loading…
Reference in a new issue