shreemaan-abhishek commented on code in PR #13391:
URL: https://github.com/apache/apisix/pull/13391#discussion_r3278973888
##########
apisix/plugins/ai-providers/base.lua:
##########
@@ -392,7 +392,12 @@ function _M.parse_streaming_response(self, ctx, res,
target_proto, converter, co
local body_reader = res.body_reader
local contents = {}
local sse_state = { is_first = true }
- local sse_buf = ""
+ -- SSE framing buffer: accumulate chunks with table.insert to avoid
+ -- allocating a new string on every append; reset to {remainder} after
+ -- each split so the table never grows beyond two elements.
+ -- Initialized with "" so the fast-path (sse_parts[1] == "") activates
+ -- immediately on the first chunk, avoiding an unnecessary table.concat.
+ local sse_parts = {""}
Review Comment:
very nice 👍🏼
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]