core :: FlatString :: substring_impl
private fun substring_impl(from, count, end_index: Int): String do
var cache = _position
var dfrom = (cache - from).abs
var dend = (end_index - from).abs
var bytefrom: Int
var byteto: Int
if dfrom < dend then
bytefrom = char_to_byte_index(from)
byteto = char_to_byte_index(end_index)
else
byteto = char_to_byte_index(end_index)
bytefrom = char_to_byte_index(from)
end
var its = _items
byteto += its.length_of_char_at(byteto) - 1
var s = new FlatString.full(its, byteto - bytefrom + 1, bytefrom, count)
return s
end
lib/core/text/flat.nit:459,2--479,4
redef fun substring_impl(from, count, end_index) do
return new ASCIIFlatString.full_data(_items, count, from + _first_byte, count)
end
lib/core/text/flat.nit:728,2--730,4