stdlib/strings: Removed from_substring constructor (replaced by with_infos)
authorLucas Bajolet <r4pass@hotmail.com>
Thu, 16 Jan 2014 17:32:22 +0000 (12:32 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Fri, 14 Feb 2014 21:18:15 +0000 (16:18 -0500)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/string.nit

index 7774dd9..810a9fd 100644 (file)
@@ -437,11 +437,13 @@ class String
 
                var realFrom = _index_from + from
 
-               if (realFrom + count) > _index_to then return new String.from_substring(realFrom, _index_to, _items)
+               if (realFrom + count) > _index_to then return new String.with_infos(_items, _index_to - realFrom + 1, realFrom, _index_to)
 
                if count == 0 then return ""
 
-               return new String.from_substring(realFrom, realFrom + count - 1, _items)
+               var to = realFrom + count - 1
+
+               return new String.with_infos(_items, to - realFrom + 1, realFrom, to)
        end
 
        redef fun substring_from(from: Int): String
@@ -549,20 +551,6 @@ class String
        #              String Specific Methods           #
        ##################################################
 
-       # Creates a String object as a substring of another String
-       #
-       # From : index to start at
-       #
-       # To : Index to stop at (from + count -1)
-       #
-       private init from_substring(from: Int, to: Int, internalString: NativeString)
-       do
-               _items = internalString
-               _index_from = from
-               _index_to = to
-               _length = to - from + 1
-       end
-
        private init with_infos(items: NativeString, len: Int, from: Int, to: Int)
        do
                self._items = items