-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Trivial performance bug in ObservableMap.replace #2003
Comments
Note that if (isPlainObject(values)) {
// could be done in single pass, but whatever
values = Object.entries(values);
}
if (Array.isArray(values)) {
values = new Map(values);
} However I think we should resolve #1980 first. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically unmarked as stale. Please disregard previous warnings. |
PR #2057 merged and waiting for the release |
published |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions. |
I have a:
No behavior change; it's just performance bug.
mobx/src/types/observablemap.ts
Line 334 in 6c1d807
I'm proposing the following trivial change:
The current behavior has quadratic complexity, with two nested loops (over all old and new keys). So for a map with a few thousands elements it may take ages, while
values.has
is supposed to be a constant-time operation (leading to linear overall complexity).The text was updated successfully, but these errors were encountered: