This rotation problem has been part of algorithmic folklore since the 60s/70s. The solution provided by jliszka showed up as early as 1971 in a text editor written by Ken Thompson.

It is interesting because it is similar to the problem of swapping adjacent regions of memory.

jliskza's solution is probably the "best" solution. It is very simple and easy to implement. It is also both space and time efficient in practice.

logiclrd's solution is probably the worst. Algorithmically it has the best constant, but in practice it suffers poorly due to cache locality. Running some benchmarks on a 1.83GHz Intel dual core, it takes twice as long to run compared to the simple reversal algorithm.

Another algorithm that tends to be even faster than the reversal one is to use a recursive swap like this:

Given s, we want to rotate by m. This is equivalent to the problem s = ab, where we want to swap a and b, and a has length m. Change ab to ablbr, where br has the same length as a. Swap a and br to get brbla. Now we have the subproblem to solve, swapping brbl. This is the same format as the original problem and leads to a recursive solution.

This algorithm can be converted to an iterative version, and is described in Gries's Science of Programming (1981). Benchmarking on a 1.83GHz Intel dual core shows it is about twice as fast as the reversal algorithm.

All of these algorithms are also discussed in John Bentley's Programming Pearls.