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 a node which is loaded from the server, it loads 170k+ other nodes under it. An exception is raised in all Array.splice.apply calls in the code :
I have soved it by creating a new method to do the splice in chunks :
function spliceApply(t,a,b,c)
{
for (var i = Math.floor(c.length / 10000); i>=0; --i)
t.splice.apply(t,[a,b].concat(c.slice(i*10000,(i+1)*10000)));
}
and transformed for example : parentNode.children.splice.apply(parentNode.children, [index, 0].concat(newNodes)) to spliceApply(parentNode.children,index,0,newNodes);
I haven't tested the code intensively but it works, hope you can fix it.
Thank you
The text was updated successfully, but these errors were encountered:
asheshv
added a commit
to asheshv/infinite-tree
that referenced
this issue
Dec 12, 2019
'Array.prototype.splice', which results into an error -
"Maximum call stack size exceeded" when working with very big arrays.
Reported By: https://github.com/YeskaNova
Issue cheton#51
I have a node which is loaded from the server, it loads 170k+ other nodes under it. An exception is raised in all Array.splice.apply calls in the code :
parentNode.children.splice.apply(parentNode.children, [index, 0].concat(newNodes));
...
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
...
this.nodes.splice.apply(this.nodes, [nodeIndex + 1, 0].concat(nodes));
this.rows.splice.apply(this.rows, [nodeIndex + 1, 0].concat(rows));
The exception is “Maximum call stack size exceeded” and it's discussed here : https://stackoverflow.com/questions/21679300/array-unshift-invoked-using-apply-causes-maximum-call-stack-size-exceeded
I have soved it by creating a new method to do the splice in chunks :
function spliceApply(t,a,b,c)
{
for (var i = Math.floor(c.length / 10000); i>=0; --i)
t.splice.apply(t,[a,b].concat(c.slice(i*10000,(i+1)*10000)));
}
and transformed for example : parentNode.children.splice.apply(parentNode.children, [index, 0].concat(newNodes)) to spliceApply(parentNode.children,index,0,newNodes);
I haven't tested the code intensively but it works, hope you can fix it.
Thank you
The text was updated successfully, but these errors were encountered: