From 8753c482334b72dd97773b1d7c0e9ffbcba4c77f Mon Sep 17 00:00:00 2001 From: Nige Date: Sat, 14 Mar 2026 22:47:48 +0000 Subject: [PATCH] perf(mcp): avoid reallocating SSE buffer on each chunk (#1153) --- src/tools/mcp/http_transport.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/mcp/http_transport.rs b/src/tools/mcp/http_transport.rs index 1548180a..ec30d7bb 100644 --- a/src/tools/mcp/http_transport.rs +++ b/src/tools/mcp/http_transport.rs @@ -212,9 +212,10 @@ impl HttpMcpTransport { } } } - // Keep only the unprocessed trailing fragment. + // Keep only the unprocessed trailing fragment without allocating + // a new String each iteration. if remaining_start > 0 { - buffer = buffer[remaining_start..].to_string(); + buffer.drain(..remaining_start); } }