Since `[]` is deprecated in strings (in favor of `.chars[]`), there
is no point of a fast implementation in FlatString.
Note that, `FlatStringCharView#[]` is already the fast path
(and is made faster by factorizing a field access)
Signed-off-by: Jean Privat <jean@pryen.org>
# AbstractString specific methods #
################################################
# AbstractString specific methods #
################################################
- redef fun [](index) do
- assert index >= 0
- # Check that the index (+ index_from) is not larger than indexTo
- # In other terms, if the index is valid
- assert (index + index_from) <= index_to
- return items[index + index_from]
- end
-
redef fun reversed
do
var native = calloc_string(self.length + 1)
redef fun reversed
do
var native = calloc_string(self.length + 1)
# Check that the index (+ index_from) is not larger than indexTo
# In other terms, if the index is valid
assert index >= 0
# Check that the index (+ index_from) is not larger than indexTo
# In other terms, if the index is valid
assert index >= 0
+ var target = self.target
assert (index + target.index_from) <= target.index_to
return target.items[index + target.index_from]
end
assert (index + target.index_from) <= target.index_to
return target.items[index + target.index_from]
end