lib/standard: remove useless repeated types in `standard`
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 28 May 2015 13:55:46 +0000 (09:55 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 28 May 2015 13:55:46 +0000 (09:55 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/standard/bytes.nit
lib/standard/collection/abstract_collection.nit
lib/standard/collection/array.nit
lib/standard/collection/range.nit
lib/standard/collection/union_find.nit
lib/standard/file.nit
lib/standard/kernel.nit
lib/standard/ropes.nit
lib/standard/string.nit

index b300298..b9b39fd 100644 (file)
@@ -31,7 +31,7 @@ class Bytes
        private var items: NativeString
 
        # Number of bytes in the array
-       redef var length: Int
+       redef var length
 
        # Capacity of the array
        private var capacity: Int
@@ -58,7 +58,7 @@ class Bytes
        #     var b = new Bytes.empty
        #     b.add 101
        #     assert b[0] == 101
-       redef fun [](i: Int): Int do
+       redef fun [](i) do
                assert i >= 0
                assert i < length
                return items[i].ascii
@@ -67,7 +67,7 @@ class Bytes
        #     var b = new Bytes.with_capacity(1)
        #     b[0] = 101
        #     assert b.to_s == "e"
-       redef fun []=(i: Int, v: Int) do
+       redef fun []=(i, v) do
                if persisted then regen
                assert i >= 0
                assert i <= length
@@ -78,7 +78,7 @@ class Bytes
        #     var b = new Bytes.empty
        #     b.add 101
        #     assert b.to_s == "e"
-       redef fun add(c: Int) do
+       redef fun add(c) do
                if persisted then regen
                if length >= capacity then
                        enlarge(length)
@@ -90,7 +90,7 @@ class Bytes
        #     var b = new Bytes.empty
        #     b.append([104, 101, 108, 108, 111])
        #     assert b.to_s == "hello"
-       redef fun append(arr: Collection[Int]) do
+       redef fun append(arr) do
                if arr isa Bytes then
                        append_ns(arr.items, arr.length)
                else
@@ -147,7 +147,7 @@ private class BytesIterator
 
        var tgt: NativeString
 
-       redef var index: Int
+       redef var index
 
        var max: Int
 
index 8b01780..16e4b1e 100644 (file)
@@ -317,7 +317,7 @@ private class ContainerIterator[E]
 
        redef fun next do is_ok = false
 
-       redef var is_ok: Bool = true
+       redef var is_ok = true
 
        var container: Container[E]
 end
@@ -1100,7 +1100,7 @@ end
 private class CoupleMapIterator[K, V]
        super MapIterator[K, V]
        redef fun item do return _iter.item.second
-       
+
        #redef fun item=(e) do _iter.item.second = e
 
        redef fun key do return _iter.item.first
index b3ec382..de66e21 100644 (file)
@@ -5,7 +5,7 @@
 #
 # This file is free software, which comes along with NIT.  This software is
 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A 
+# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A
 # PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
 # is kept unaltered, and a notification of the changes is added.
 # You  are  allowed  to  redistribute it and sell it, alone or is a part of
@@ -65,8 +65,7 @@ abstract class AbstractArrayRead[E]
 
        redef fun last_index_of(item) do return last_index_of_from(item, length-1)
 
-       redef fun index_of_from(item, pos)
-       do
+       redef fun index_of_from(item, pos) do
                var i = pos
                var len = length
                while i < len do
@@ -78,8 +77,7 @@ abstract class AbstractArrayRead[E]
                return -1
        end
 
-       redef fun last_index_of_from(item, pos)
-       do
+       redef fun last_index_of_from(item, pos) do
                var i = pos
                while i >= 0 do
                        if self[i] == item then
@@ -242,8 +240,7 @@ abstract class AbstractArray[E]
                self[0] = item
        end
 
-       redef fun insert(item: E, pos: Int)
-       do
+       redef fun insert(item, pos) do
                enlarge(length + 1)
                copy_to(pos, length-pos, self, pos + 1)
                self[pos] = item
index c611ec1..29fa17e 100644 (file)
@@ -19,7 +19,7 @@ import abstract_collection
 class Range[E: Discrete]
        super Collection[E]
 
-       redef var first: E
+       redef var first
 
        # Get the last element.
        var last: E
index f4c6baa..b44b7f9 100644 (file)
@@ -115,8 +115,7 @@ class DisjointSet[E]
        #     s.add(1)
        #     assert s.has(1)
        #     assert not s.has(2)
-       redef fun has(e)
-       do
+       redef fun has(e) do
                return nodes.has_key(e)
        end
 
@@ -126,8 +125,7 @@ class DisjointSet[E]
        # Initially it is in its own disjoint subset
        #
        # ENSURE: `has(e)`
-       redef fun add(e:E)
-       do
+       redef fun add(e) do
                if nodes.has_key(e) then return
                var ne = new DisjointSetNode
                nodes[e] = ne
index 5a89d10..3bad3f3 100644 (file)
@@ -135,7 +135,7 @@ class FileReader
        end
 
        # End of file?
-       redef var end_reached: Bool = false
+       redef var end_reached = false
 
        # Open the file at `path` for reading.
        #
@@ -299,7 +299,7 @@ class Stdin
                prepare_buffer(1)
        end
 
-       redef fun poll_in: Bool is extern "file_stdin_poll_in"
+       redef fun poll_in is extern "file_stdin_poll_in"
 end
 
 # Standard output stream.
index 85386b4..ffd684a 100644 (file)
@@ -5,7 +5,7 @@
 #
 # This file is free software, which comes along with NIT.  This software is
 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A 
+# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A
 # PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
 # is kept unaltered, and a notification of the changes is added.
 # You  are  allowed  to  redistribute it and sell it, alone or is a part of
@@ -128,7 +128,7 @@ interface Comparable
        type OTHER: Comparable
 
        # Is `self` lesser than `other`?
-       fun <(other: OTHER): Bool is abstract 
+       fun <(other: OTHER): Bool is abstract
 
        # not `other` < `self`
        # Note, the implementation must ensure that: `(x<=y) == (x<y or x==y)`
@@ -331,10 +331,10 @@ universal Float
        redef fun !=(i) is intern
        redef fun output is intern
 
-       redef fun <=(i): Bool is intern
-       redef fun <(i): Bool is intern
-       redef fun >=(i): Bool is intern
-       redef fun >(i): Bool is intern
+       redef fun <=(i) is intern
+       redef fun <(i) is intern
+       redef fun >=(i) is intern
+       redef fun >(i) is intern
 
        redef fun +(i) is intern
        redef fun - is intern
@@ -483,9 +483,9 @@ universal Int
 
        redef fun is_between(c, d)
        do
-               if self < c or d < self then 
+               if self < c or d < self then
                        return false
-               else 
+               else
                        return true
                end
        end
@@ -536,7 +536,7 @@ universal Int
                # count digits
                while n > 0 do
                        d += 1
-                       n = n / b       # euclidian division /
+                       n = n / b       # euclidian division /
                end
                return d
        end
index 5ac6ee2..902649a 100644 (file)
@@ -74,7 +74,7 @@ end
 private class Concat
        super RopeString
 
-       redef var length: Int is noinit
+       redef var length is noinit
 
        redef fun substrings do return new RopeSubstrings(self)
 
@@ -159,7 +159,6 @@ private class Concat
        end
 
        redef fun copy_to_native(dest, n, src_offset, dest_offset) do
-               var remlen = n
                var subs = new RopeSubstrings.from(self, src_offset)
                var st = src_offset - subs.pos
                var off = dest_offset
@@ -827,7 +826,7 @@ class RopeBufferIter
        # Maximum position iterable.
        var maxpos: Int
 
-       redef var index: Int
+       redef var index
 
        # Init the iterator from a RopeBuffer.
        init(t: RopeBuffer) is old_style_init do
@@ -877,7 +876,7 @@ class RopeBufferReviter
        # Current position in `ns`.
        var pns: Int
 
-       redef var index: Int
+       redef var index
 
        # Init the iterator from a RopeBuffer.
        init(tgt: RopeBuffer) is old_style_init do
index 61af948..60f3af9 100644 (file)
@@ -898,8 +898,8 @@ abstract class Text
        #
        # REQUIRE: `n` must be large enough to contain `len` bytes
        #
-       #       var ns = new NativeString(8)
-       #       "Text is String".copy_to_native(ns, 8, 2, 0)
+       #       var ns = new NativeString(8)
+       #       "Text is String".copy_to_native(ns, 8, 2, 0)
        #       assert ns.to_s_with_length(8) == "xt is St"
        #
        fun copy_to_native(dest: NativeString, n, src_offset, dest_offset: Int) do
@@ -945,7 +945,7 @@ abstract class FlatText
        # copy locally the char* as Nit Strings are immutable.
        private fun fast_cstring: NativeString is abstract
 
-       redef var length: Int = 0
+       redef var length = 0
 
        redef fun output
        do
@@ -1194,7 +1194,7 @@ class FlatString
        # Indes in _items of the last item of the string
        private var index_to: Int is noinit
 
-       redef var chars: SequenceRead[Char] = new FlatStringCharView(self) is lazy
+       redef var chars = new FlatStringCharView(self) is lazy
 
        redef fun [](index)
        do
@@ -1319,8 +1319,7 @@ class FlatString
                index_to = to
        end
 
-       redef fun to_cstring: NativeString
-       do
+       redef fun to_cstring do
                if real_items != null then
                        return real_items.as(not null)
                else
@@ -1738,8 +1737,7 @@ class FlatBuffer
                capacity = c
        end
 
-       redef fun to_s: String
-       do
+       redef fun to_s do
                written = true
                if length == 0 then items = new NativeString(1)
                return new FlatString.with_infos(items, length, 0, length - 1)