transform: do not transform rranges in for; this reactivates the short-range optimisation
authorJean Privat <jean@pryen.org>
Fri, 8 Aug 2014 04:17:59 +0000 (00:17 -0400)
committerJean Privat <jean@pryen.org>
Fri, 8 Aug 2014 15:10:50 +0000 (11:10 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/transform.nit

index 5395559..6829d75 100644 (file)
@@ -191,6 +191,7 @@ redef class ACrangeExpr
        # `[x..y]` is replaced with `new Range[X](x,y)`
        redef fun accept_transform_visitor(v)
        do
+               if parent isa AForExpr then return # to permit shortcut ranges
                replace_with(v.builder.make_new(init_callsite.as(not null), [n_expr, n_expr2]))
        end
 end
@@ -199,6 +200,7 @@ redef class AOrangeExpr
        # `[x..y[` is replaced with `new Range[X].without_last(x,y)`
        redef fun accept_transform_visitor(v)
        do
+               if parent isa AForExpr then return # to permit shortcut ranges
                replace_with(v.builder.make_new(init_callsite.as(not null), [n_expr, n_expr2]))
        end
 end