mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
simplfy generated code for static ranges
This commit is contained in:
@@ -578,8 +578,12 @@ exports.RangeNode: class RangeNode extends BaseNode
|
||||
i: o.scope.freeVariable()
|
||||
pre: "\n${idt}${result} = []; ${vars}"
|
||||
if @fromNum and @toNum
|
||||
o.index: i
|
||||
body: @compileSimple o
|
||||
if Math.abs(+@fromNum - +@toNum) >= 20
|
||||
o.index: i
|
||||
body: @compileSimple o
|
||||
else
|
||||
range: if @exclusive then [+@fromNum...+@toNum] else [+@fromNum..+@toNum]
|
||||
return "[${range.join(', ')}]"
|
||||
else
|
||||
clause: "$@fromVar <= $@toVar ?"
|
||||
body: "var $i = $@fromVar; $clause $i <$@equals $@toVar : $i >$@equals $@toVar; $clause $i += 1 : $i -= 1"
|
||||
|
||||
Reference in New Issue
Block a user