Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace setHeaders function with optimized inline header setting #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Phillip9587
Copy link
Contributor

Replaced the setHeaders function with a loop that sets headers directly using Object.entries. This change eliminates the need for the separate setHeaders function.

@@ -288,7 +288,9 @@ function send (req, res, status, headers, message) {
res.removeHeader('Content-Range')

// response headers
setHeaders(res, headers)
for (const [key, value] of Object.entries(headers ?? {})) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to do some bench-marking on this. I don't want to armchair micro-benchmark on this, but I am pretty sure that this is making a unnecessary array per header and may be slower than the array from. Either way, these are the kind of changes that I want us to have a easy and reliable way to truly test the perf of before landing..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants