-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
perf: optimize content-type and schema parsing, fix grammar in warnings #6261
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Nitin <nitinjha2609@gmail.com>
Signed-off-by: Nitin <nitinjha2609@gmail.com>
Signed-off-by: Nitin <nitinjha2609@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Hey @mcollina, thanks for the review and approval! Looks like the PR is just waiting on workflow approval now. Let me know if anything else is needed! |
Node: 20 Node: 22 Node: 24 |
Node: 20 Node: 22 Node: 24 |
I added the Happy to revert this if consistency or raw performance is preferred. Just wanted to ensure we're not doing redundant work if the value already exists. |
Signed-off-by: Nitin <150040530+nitin-is-me@users.noreply.github.com>
This looks to be slower from the benchmarks? From what I understand, Better optimisation could be just caching the |
@Fdawgs Totally get the benchmark concern, but just double-checked the actual context here:
Plus, avoiding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I missed it, but where do we verify contentProperty
's prototype chain?
AFAICT, we verify schema
's proto chain an not schema.content
's
Thanks for raising that, @gurgunday.
Therefore, because the parent This approach leverages the existing checks to gain a small memory allocation benefit while maintaining correctness for the expected schema shapes. |
Tentative on change after further discussions.
Description
This PR optimizes
content-type
header parsing, schema iteration in thenormalizeSchema
function and rectifies few grammatical mistakes in warnings file.Changes Made
content-type
header parsing in validation fileObject.keys(contentProperty)
withfor...in
loop in body schema fileObject.keys(contentProperty)
withfor...in
loop in response schema fileChecklist
npm run test && npm run benchmark --if-present
and the Code of conduct