Here's some refactoring of the common code for dealing with rolling windows.
The first patch factors out the WriteWindow methods to a function in an internal package. The WriteWindow methods are now so small that they get inlined, so callers still do a single function call (not counting the Write calls).
The second factors out the re-arranging, while changing the algorithm to operate in-place (no allocation).
Here's some refactoring of the common code for dealing with rolling windows.
The first patch factors out the WriteWindow methods to a function in an internal package. The WriteWindow methods are now so small that they get inlined, so callers still do a single function call (not counting the Write calls).
The second factors out the re-arranging, while changing the algorithm to operate in-place (no allocation).