let split_lines s =
let rev_lst = ref [] in
let buff = Buffer.create 13 in
let flush () =
rev_lst := Buffer.contents buff :: !rev_lst;
Buffer.clear buff
in
if String.length s > 0 then
begin
String.iter
(function
| '\n' -> flush ()
| c -> Buffer.add_char buff c)
s;
flush ();
List.rev !rev_lst
end
else
[]