From 2876718210178db49f2316b7dcb90c611fe66454 Mon Sep 17 00:00:00 2001 From: Poggles Date: Sat, 12 Jan 2013 20:08:50 +0000 Subject: [PATCH] Make awful.util.cycle() less while'y Signed-off-by: Uli Schlachter --- lib/awful/util.lua.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/awful/util.lua.in b/lib/awful/util.lua.in index 60d217f3..8b438c38 100644 --- a/lib/awful/util.lua.in +++ b/lib/awful/util.lua.in @@ -55,8 +55,10 @@ end -- @return An integer in (1, t) or nil if t is less than or equal to zero. function util.cycle(t, i) if t < 1 then return end - while i > t do i = i - t end - while i < 1 do i = i + t end + i = i % t + if i == 0 then + i = t + end return i end