The existing implementation always binary searches over the entire index vector. However, we should always be doing lookups in increasing order, so we can actually "consume" the index vector instead by moving up the lower search bound each time. This also lets us use the expsearch function instead because we now have reason to believe that the lower bound is close to the true value.
@willow-ahrens Just wanted to bump this because I'd forgotten about it. It doesn't seem like the python test failure is related to the PR, but I'm not sure.
The existing implementation always binary searches over the entire index vector. However, we should always be doing lookups in increasing order, so we can actually "consume" the index vector instead by moving up the lower search bound each time. This also lets us use the expsearch function instead because we now have reason to believe that the lower bound is close to the true value.
Before Change:
After change:
Could use a close look though, I'm not 100% sure how the lowering works with 'thunk'