From bc1e5920db228d85d67a056f42146bf39b7c01e7 Mon Sep 17 00:00:00 2001 From: Kevin Matz Date: Mon, 29 Oct 2018 17:19:18 -1000 Subject: [PATCH] cleanup span calculation --- OscCommentMacroListener.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/OscCommentMacroListener.py b/OscCommentMacroListener.py index 3092a6b..07d41bc 100644 --- a/OscCommentMacroListener.py +++ b/OscCommentMacroListener.py @@ -45,14 +45,6 @@ def beautify_lisp_string(in_string): return out_string -# floating point ranges -def frange(start, stop, step=1): - i = start - while i < stop: - yield i - i += step - - class HogDevice(): # button state constants buttonDOWN = 1 @@ -123,10 +115,11 @@ class OscCommentMacroListener(CommentMacroListener): ctx.parentCtx.targets.append(ctx.value) def exitSpan(self, ctx: CommentMacroParser.SpanContext): - minimum = min(ctx.n1.value, ctx.n2.value) - maximum = max(ctx.n1.value, ctx.n2.value) - for i in (frange(minimum, maximum + 1)): - ctx.parentCtx.targets.append(i) + lower = min(ctx.n1.value, ctx.n2.value) + upper = max(ctx.n1.value, ctx.n2.value) + while lower <= upper: + ctx.parentCtx.targets.append(lower) + lower += 1 def exitMasterGo(self, ctx: CommentMacroParser.MasterGoContext): if ctx.target() is None: