Make awful.util.cycle() less while'y

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Poggles 2013-01-12 20:08:50 +00:00 committed by Uli Schlachter
parent 2e38c08569
commit 2876718210
1 changed files with 4 additions and 2 deletions

View File

@ -55,8 +55,10 @@ end
-- @return An integer in (1, t) or nil if t is less than or equal to zero. -- @return An integer in (1, t) or nil if t is less than or equal to zero.
function util.cycle(t, i) function util.cycle(t, i)
if t < 1 then return end if t < 1 then return end
while i > t do i = i - t end i = i % t
while i < 1 do i = i + t end if i == 0 then
i = t
end
return i return i
end end