Skip to content

Resolve stack overflow in SortedSet.reduce and reduceRight#244

Open
alex-dunn wants to merge 1 commit into
montagejs:masterfrom
alex-dunn:sorted-set-stack-overflow-#150
Open

Resolve stack overflow in SortedSet.reduce and reduceRight#244
alex-dunn wants to merge 1 commit into
montagejs:masterfrom
alex-dunn:sorted-set-stack-overflow-#150

Conversation

@alex-dunn
Copy link
Copy Markdown

closes #150, Resolve stack overflow for SortedSet reduce & reduceRight

Replace recursive implementation with version that uses the Iterator. The limit in size of the set now seems to be whenever the browser runs out of memory to allocate for the main tree + the history tree in splay.
Updated the Iterator to take a 4th argument: reverse. If reverse is falsey then behaviour is the same as master, otherwise it will iterator through the set in the reverse order.

Replace implementations of SortedSet.reduce and reduceRight.
Current implementations are recursive and so will inevitably
hit a stack overflow exception at some point.
New implementations use the Iterator to traverse the tree.
@hthetiot hthetiot requested a review from marchant August 12, 2021 11:14
@hthetiot hthetiot added the bug label Aug 12, 2021
@hthetiot
Copy link
Copy Markdown
Contributor

Possible duplicate 85f00f8

@hthetiot
Copy link
Copy Markdown
Contributor

Fix confirmed on master via this comment #241 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SortedMap.forEach throws RangeError when > 10000 items in map

2 participants