This functionality used to be in `split()` but that function was getting complicated. This just moves the split index determination to its own function.