core::hash_collection: simplify `enlarge`
authorJean Privat <jean@pryen.org>
Tue, 20 Oct 2015 00:19:12 +0000 (20:19 -0400)
committerJean Privat <jean@pryen.org>
Tue, 20 Oct 2015 00:19:12 +0000 (20:19 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/core/collection/hash_collection.nit

index 7c9fc6a..890ecd9 100644 (file)
@@ -165,7 +165,6 @@ private abstract class HashCollection[K]
        # Force a capacity
        fun enlarge(cap: Int)
        do
-               var old_cap = _capacity
                # get a new capacity
                if cap < _the_length + 1 then cap = _the_length + 1
                if cap <= _capacity then return
@@ -176,16 +175,6 @@ private abstract class HashCollection[K]
                var new_array = new NativeArray[nullable N](cap)
                _array = new_array
 
-               # clean the new array
-               var i = cap - 1
-               while i >=0 do
-                       new_array[i] = null
-                       i -= 1
-               end
-
-               if _the_length == 0 then return
-               if _capacity <= old_cap then return
-
                # Reput items in the array
                var node = _first_item
                while node != null do