Optimize Array#rotate!(n) for n = 1 and n = -1
For the most common cases of rotate! one place to the right or to the left, instead of doing some reversals of the array we just keep a single value in a temporary value, use memmove and then put the temporary value where it should be.
rotate!
Optimize Array#rotate!(n) for n = 1 and n = -1
For the most common cases of
rotate!one place to the right or to theleft, instead of doing some reversals of the array we just keep a single
value in a temporary value, use memmove and then put the temporary
value where it should be.