Author: pmichaud
Date: Sun Dec 14 10:43:37 2008
New Revision: 33896

Modified:
   trunk/languages/perl6/src/classes/List.pir

Log:
[rakudo]: Optimize flattening a bit further.
When splicing in a flattened element, we don't need to
re-flatten the things we just spliced in.


Modified: trunk/languages/perl6/src/classes/List.pir
==============================================================================
--- trunk/languages/perl6/src/classes/List.pir  (original)
+++ trunk/languages/perl6/src/classes/List.pir  Sun Dec 14 10:43:37 2008
@@ -239,14 +239,18 @@
     $I0 = can elem, '!flatten'
     if $I0 goto flat_elem
     $I0 = does elem, 'array'
-    if $I0 goto flat_splice
+    unless $I0 goto flat_next
+    splice self, elem, i, 1
+    len = elements self
+    goto flat_loop
   flat_next:
     inc i
     goto flat_loop
   flat_elem:
     elem = elem.'!flatten'()
-  flat_splice:
     splice self, elem, i, 1
+    $I0 = elements elem
+    i += $I0
     len = elements self
     goto flat_loop
   flat_end:

Reply via email to