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: memoize toJSON / toObject default options #14672

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

vkarpov15
Copy link
Collaborator

Summary

Re: #14394, we can get a maybe 2.5% speedup by not combining Mongoose global options and schema base options every time we call $toObject(). Not a huge speedup, but every little bit helps given that $toObject() is called on some heavily used code paths, like save() and JSON.stringify().

I'll put this change in 8.5, just to de-risk because it may cause some issues for people who modify toJSON and toObject options after compiling their schemas.

Examples

@vkarpov15 vkarpov15 added this to the 8.5 milestone Jun 17, 2024
@vkarpov15 vkarpov15 changed the base branch from master to 8.5 June 18, 2024 15:10
@vkarpov15 vkarpov15 merged commit 0502d2b into 8.5 Jun 18, 2024
46 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14394-memoize-defaultoptions branch June 18, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants