Ensure at least a given capacity

If the current capacity is enough, then no-op.

Property definitions

core $ CircularArray :: enlarge
	# Ensure at least a given capacity
	#
	# If the current capacity is enough, then no-op.
	fun enlarge(capacity: Int)
	do
		# First allocation
		if not isset _native then
			var new_c = 8
			while new_c < capacity do new_c *= 2
			native = new NativeArray[E](new_c)
			return
		end

		# Compute more capacity
		var c = native.length
		if capacity <= c then return
		var new_c = c
		while new_c < capacity do new_c *= 2

		var new_native = new NativeArray[E](new_c)

		# Reallocation: just realign the parts on 0
		if head > tail then
			# Two parts
			native.memmove(head, c-head, new_native, 0)
			native.memmove(0, tail+1, new_native, c-head)
		else
			# One part
			native.memmove(head, length, new_native, 0)
		end
		head = 0
		tail = length - 1
		native = new_native
	end
lib/core/collection/circular_array.nit:165,2--198,4