haskell / haskell/containers

Can we improve bounds checks for splitAt?

Open
#244 0 comments 0 reactions 0 assignees View on GitHub
performance Seq
Dominant language
Haskell
Stars
355
Forks
194
Avg merge
3d 4h
Merged PRs (30d)
4

Description

Currently, we check whether the split point is within the sequence, and, if so, call `splitTreeE` to handle it. That doesn't seem to make a lot of logical sense, because checking that requires pattern matching on the tree, and then `splitTreeE` immediately matches on it again. I tried moving the bounds check into the `splitTreeE` cases, and that was bad. It seems that doing so confused the inliner or something, and stuff got slower. The Core looked weird, with a case-of-case join point that ignored its `Int` argument. Inlining `splitMiddleE` helped some things, but made others worse. I'd like to see a non-fragile solution.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.