tty: vt: separate array juggling to juggle_array()
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Thu, 12 Jan 2023 08:01:34 +0000 (09:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jan 2023 14:06:42 +0000 (15:06 +0100)
commit8aad24ad9d0498747e55aa89879a96cedb926be2
treee13c1a27a4a7c2fefb647eec0d20d3fc5a0d8306
parent287696d5b4112bb7d78bdeda713cc44f93f30765
tty: vt: separate array juggling to juggle_array()

The algorithm used for scrolling is the array juggling. It has
complexity O(N) and space complexity O(1). I.e. quite fast w/o
requirements for temporary storage.

Move the algorithm to a separate function so it is obvious what it is.
It is almost generic (except the array type), so if anyone else wants
array rotation, feel free to make it generic and move it to include/.

And rename all the variables from i, j, k, sz, d, and so on to something
saner.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230112080136.4929-9-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c