This should be implemented in pure-ruby, in general methods that contain loops that invoke blocks should always be written in Ruby so the JIT can specialize them.

If you want to split this into 2 PRs, the slice bit is ready to go.