lib/standard/ropes: Adapted write for performance with other String representations.
authorLucas Bajolet <r4pass@hotmail.com>
Mon, 9 Jun 2014 15:58:44 +0000 (11:58 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Mon, 9 Jun 2014 15:58:44 +0000 (11:58 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/file.nit

index 27b2626..f82a1fd 100644 (file)
@@ -16,7 +16,7 @@
 module file
 
 intrude import stream
-intrude import string
+intrude import ropes
 import string_search
 import time
 
@@ -134,7 +134,11 @@ class OFStream
        redef fun write(s)
        do
                assert _writable
-               write_native(s.to_cstring, s.length)
+               if s isa FlatText then
+                       write_native(s.to_cstring, s.length)
+               else
+                       for i in s.substrings do write_native(i.to_cstring, i.length)
+               end
        end
 
        redef fun is_writable do return _writable