Merge: Annotation lateinit
[nit.git] / lib / standard / ropes.nit
index 7f1ba2b..902649a 100644 (file)
@@ -74,7 +74,7 @@ end
 private class Concat
        super RopeString
 
-       redef var length: Int is noinit
+       redef var length is noinit
 
        redef fun substrings do return new RopeSubstrings(self)
 
@@ -157,6 +157,26 @@ private class Concat
                        return new Concat(left, r + s)
                end
        end
+
+       redef fun copy_to_native(dest, n, src_offset, dest_offset) do
+               var subs = new RopeSubstrings.from(self, src_offset)
+               var st = src_offset - subs.pos
+               var off = dest_offset
+               while n > 0 do
+                       var it = subs.item
+                       if n > it.length then
+                               var cplen = it.length - st
+                               it.items.copy_to(dest, cplen, st, off)
+                               off += cplen
+                               n -= cplen
+                       else
+                               it.items.copy_to(dest, n, st, off)
+                               n = 0
+                       end
+                       subs.next
+                       st = 0
+               end
+       end
 end
 
 # Mutable `Rope`, optimized for concatenation operations
@@ -806,7 +826,7 @@ class RopeBufferIter
        # Maximum position iterable.
        var maxpos: Int
 
-       redef var index: Int
+       redef var index
 
        # Init the iterator from a RopeBuffer.
        init(t: RopeBuffer) is old_style_init do
@@ -856,7 +876,7 @@ class RopeBufferReviter
        # Current position in `ns`.
        var pns: Int
 
-       redef var index: Int
+       redef var index
 
        # Init the iterator from a RopeBuffer.
        init(tgt: RopeBuffer) is old_style_init do