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

perf(parse): remove additional slice for quoted values #143

Closed
wants to merge 1 commit into from

Conversation

kurtextrem
Copy link
Contributor

@kurtextrem kurtextrem commented Jul 14, 2022

see fastify/fastify-cookie#194 (comment)

Before & after as diff:
https://www.diffchecker.com/hO2It0SH on node v16 (unquote -> +300 000 op/s)

val = val.slice(1, -1)
}
var val = (str.charCodeAt(eqIdx) === 0x22)
? str.slice(eqIdx + 1, endIdx - 1).trim()
Copy link
Member

Choose a reason for hiding this comment

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

I like this change for performance, but I think this changes the behavior. Before it trimmed whitespace around potential quotes, but now it'd trim whitespace within quotes.

@blakeembrey
Copy link
Member

Going to close this out, I managed to get an extra 10% perf boost across the board by instead iterating using a loop over whitespace (no more trim at all) in #170, and it maintains backward compatibility with the quote characters.

@blakeembrey blakeembrey closed this Oct 2, 2024
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