From 4dd8b2b4353626f9c997905fcc9f4824558c1438 Mon Sep 17 00:00:00 2001 From: EdamAmex <121654029+EdamAme-x@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:55:49 +0900 Subject: [PATCH] perf(context): improve performance of context (setHeaders) (#3592) * perf(context): improve performance of context (newResponse, setHeaders) * Revert context.ts --- src/context.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/context.ts b/src/context.ts index 7acab14f..a23942e0 100644 --- a/src/context.ts +++ b/src/context.ts @@ -266,7 +266,10 @@ export const TEXT_PLAIN = 'text/plain; charset=UTF-8' * @returns The updated Headers object. */ const setHeaders = (headers: Headers, map: Record = {}) => { - Object.entries(map).forEach(([key, value]) => headers.set(key, value)) + for (let i = 0, keys = Object.keys(map), len = keys.length; i < len; i++) { + const key = keys[i] + headers.set(key, map[key]) + } return headers }