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

fix(document): make array $shift() use $pop instead of overwriting array #13004

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

vkarpov15
Copy link
Collaborator

Summary

Looks like in Mongoose 6.0.0, our switch to using proxies for arrays broke some internal behavior for $shift(). The TLDR; is that $shift() mistakenly always becomes a $set, as opposed to a $pop, since 6.0.0. Which may have performance implications for large arrays.

This issue was happening because 1) setting _shifted on the array proxy triggers a $set, and 2) calling shift() on an array proxy also triggers a $set.

Examples

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! 👍

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

LGTM

@vkarpov15 vkarpov15 merged commit b100c92 into master Feb 8, 2023
@vkarpov15 vkarpov15 deleted the vkarpov15/shift-fix branch February 8, 2023 02:27
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.

None yet

3 participants