From f7646bcc485f43ff4ba987cd613891883a081a07 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 9 Jun 2024 00:04:42 -0500 Subject: [PATCH] actix-web-actors: take the internal buffer when yielding (#3369) * actix-web-actors: take the internal buffer when yielding * actix-web-actors: Add CHANGES entry re: taking buffer --- actix-web-actors/CHANGES.md | 1 + actix-web-actors/src/ws.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index 9a622d8da..3e854c0b8 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Take the encoded buffer when yielding bytes in the response stream rather than splitting the buffer, reducing memory use - Minimum supported Rust version (MSRV) is now 1.72. ## 4.3.0 diff --git a/actix-web-actors/src/ws.rs b/actix-web-actors/src/ws.rs index 1fb903225..7f7607fa9 100644 --- a/actix-web-actors/src/ws.rs +++ b/actix-web-actors/src/ws.rs @@ -710,7 +710,7 @@ where } if !this.buf.is_empty() { - Poll::Ready(Some(Ok(this.buf.split().freeze()))) + Poll::Ready(Some(Ok(std::mem::take(&mut this.buf).freeze()))) } else if this.fut.alive() && !this.closed { Poll::Pending } else {