Optimize index functions for FFI iterator