message: make retain_headers more efficient

Avoid an intermediate string allocation; we can write directly
to the new buffer.
This commit is contained in:
Wez Furlong
2023-08-25 08:55:30 -07:00
parent ed07a07e11
commit a36eee80f0
+1 -1
View File
@@ -651,7 +651,7 @@ impl Message {
if !retain {
continue;
}
new_data.extend_from_slice(hdr.to_header_string().as_bytes());
hdr.write_header(&mut new_data)?;
}
new_data.extend_from_slice(b"\r\n");
new_data.extend_from_slice(&data[body_offset..]);