lib/core/flat: `bytepos` and `position` cache are now private
authorLucas Bajolet <r4pass@hotmail.com>
Mon, 31 Aug 2015 20:06:31 +0000 (16:06 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Thu, 3 Sep 2015 19:35:45 +0000 (15:35 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/core/text/flat.nit

index 5c96bb7..fa45554 100644 (file)
@@ -41,10 +41,10 @@ redef class FlatText
        private fun last_byte: Int do return _bytelen - 1
 
        # Cache of the latest position (char) explored in the string
-       var position: Int = 0
+       private var position: Int = 0
 
        # Cached position (bytes) in the NativeString underlying the String
-       var bytepos: Int = first_byte is lateinit
+       private var bytepos: Int = 0
 
        # Index of the character `index` in `_items`
        private fun char_to_byte_index(index: Int): Int do
@@ -241,6 +241,7 @@ class FlatString
                self._bytelen = bytelen
                _first_byte = from
                _last_byte = to
+               _bytepos = from
        end
 
        # Low-level creation of a new string with all the data.
@@ -254,6 +255,7 @@ class FlatString
                self._bytelen = bytelen
                _first_byte = from
                _last_byte = to
+               _bytepos = from
        end
 
        redef fun to_cstring do