end
+redef class FlatText
+
+ # Creates a substring, only without any copy overhead for Buffers
+ # The call to lazy_substring ensures the creation of a FlatString, which is required for Leaves.
+ private fun lazy_substring(from: Int, length: Int): FlatString is abstract
+
+ # Same as substring_from, but without copy of the data for Buffers.
+ private fun lazy_substring_from(from: Int): FlatString is abstract
+end
+
+redef class FlatBuffer
+
+ # Same as to_s, only will not copy self before returning a String.
+ private fun lazy_to_s(len: Int): FlatString
+ do
+ return new FlatString.with_infos(items, len, 0, length - 1)
+ end
+
+ redef fun lazy_substring(from,length)
+ do
+ return new FlatString.with_infos(items, length, from, from + length - 1)
+ end
+
+ redef fun lazy_substring_from(from)
+ do
+ var newlen = length - from
+ return new FlatString.with_infos(items, newlen, from, from + newlen - 1)
+ end
+
+end
+
+redef class FlatString
+
+ redef fun lazy_substring(from, len) do return substring(from,len).as(FlatString)
+
+ redef fun lazy_substring_from(from) do return substring_from(from).as(FlatString)
+
+end
+
redef class Rope
# Empty Rope