Closed Groostav closed 5 years ago
Thanks for the report! I wish Java had tail call optimization, oh well.
Should be an easy fix to convert the recursion to a loop—feel free to submit a pull request but if not I'll try to get to it soon
Pushed a fix! Also fixed ConsPStack.subList
. I'll do a version bump and release soon.
I think there are probably a few other places where we should convert recursive implementations to iterative ones, I'll make a separate issue about that
v3.0.4 is released with the fix, thanks again for the bug report
@hrldcpr would it be possible to do an optimization to reduce gc thrashing by navigating down to the required node before returning a new PTreeVector
?
Yeah sure, good idea! f58c25f makes this change. v3.0.5 is being released to include it.
There will still be numerous calls to new IntTree
but that's harder to avoid.
(Also created #76 to track making this optimization elsewhere)
when calling
sublist
for reasonably large list, result is stack-overflow. The implementation is recursive with a stack-depth that O(n) on the number of elements => large lists produce stack-overflow errors.to repro:
TreePVector
expected: fast operation on shared subcomponents produces a wrapper on new list actual: stack-overflow on recursion of sublist:
kotlin SSCCE: