From 2e1f29c7bc8994b6dcb8b83625f337debca23806 Mon Sep 17 00:00:00 2001 From: tang <38900255+WeiTang-star@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:51:19 +0800 Subject: [PATCH] Optimize socket read (#40) * Optimize JSON parsing from socket stream with JSONStream and improved buffer handling for better performance * Refactor socket reading logic: Replace previous socket.read implementation with a more efficient JSON streaming parser --------- Signed-off-by: tang <38900255+WeiTang-star@users.noreply.github.com> --- api/custom_module/sharkd_dict.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/api/custom_module/sharkd_dict.js b/api/custom_module/sharkd_dict.js index f639cd5..a1581b9 100644 --- a/api/custom_module/sharkd_dict.js +++ b/api/custom_module/sharkd_dict.js @@ -186,15 +186,6 @@ send_req = async function(request, sock) { return null; } - let data = ''; - let chunk = await new_sock.read(); - - data += chunk; - while (_str_is_json(data) === false) { - chunk = await new_sock.read(); - data += chunk; - } - let result = await readAndParseSocket(new_sock); if ("result" in result) {