You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an application that stores a large number of plain objects in an array. Using Object.freeze I can prevent Vue from making the items in the array reactive, but whenever I replace the array with a new frozen array, Vue tries to traverse all of the items anyway.
Since the array itself is reactive (as a property on its parent object), I believe the traversal is caused by the following in traverse():
if (isA) {
i = val.length;
while (i--) traverse(val[i], seen);
}
I've been able to fix the problem by adding this line:
if (!Object.isExtensible(val)) return
Immediately inside of:
if (isA || isO) {
if (!Object.isExtensible(val)) return // Addition
if (val.__ob__) {
var depId = val.__ob__.dep.id;
...
Comparing JS profiles with/without that line gives a dramatic increase in speed for me. Since it's frozen, there won't be any getters in there anyway so why look? Instead of maintaining my own fork, I wanted to see if there was a reason this shouldn't be added into core.
The text was updated successfully, but these errors were encountered:
I have an application that stores a large number of plain objects in an array. Using
Object.freeze
I can prevent Vue from making the items in the array reactive, but whenever I replace the array with a new frozen array, Vue tries to traverse all of the items anyway.Since the array itself is reactive (as a property on its parent object), I believe the traversal is caused by the following in
traverse()
:I've been able to fix the problem by adding this line:
Immediately inside of:
Comparing JS profiles with/without that line gives a dramatic increase in speed for me. Since it's frozen, there won't be any getters in there anyway so why look? Instead of maintaining my own fork, I wanted to see if there was a reason this shouldn't be added into core.
The text was updated successfully, but these errors were encountered: