lib/strings: remove redefinition `FlatString#[]`
authorJean Privat <jean@pryen.org>
Fri, 4 Apr 2014 14:32:22 +0000 (10:32 -0400)
committerJean Privat <jean@pryen.org>
Fri, 4 Apr 2014 18:16:08 +0000 (14:16 -0400)
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>

lib/standard/string.nit

index 4d3abc1..ce15ffd 100644 (file)
@@ -669,14 +669,6 @@ class FlatString
        #       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)
@@ -990,6 +982,7 @@ private class FlatStringCharView
                # 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