Join all the elements using to_s

REQUIRE: self isa NativeArray[String]

REQUIRE: all elements are initialized

Property definitions

core :: abstract_text $ NativeArray :: native_to_s
	# Join all the elements using `to_s`
	#
	# REQUIRE: `self isa NativeArray[String]`
	# REQUIRE: all elements are initialized
	fun native_to_s: String is abstract
lib/core/text/abstract_text.nit:2563,2--2567,36

core :: flat $ NativeArray :: native_to_s
	redef fun native_to_s do
		assert self isa NativeArray[String]
		var l = length
		var na = self
		var i = 0
		var sl = 0
		var mypos = 0
		while i < l do
			sl += na[i].byte_length
			i += 1
			mypos += 1
		end
		var ns = new CString(sl + 1)
		ns[sl] = 0
		i = 0
		var off = 0
		while i < mypos do
			var tmp = na[i]
			if tmp isa FlatString then
				var tpl = tmp._byte_length
				tmp._items.copy_to(ns, tpl, tmp._first_byte, off)
				off += tpl
			else
				for j in tmp.substrings do
					var s = j.as(FlatString)
					var slen = s._byte_length
					s._items.copy_to(ns, slen, s._first_byte, off)
					off += slen
				end
			end
			i += 1
		end
		return new FlatString.with_infos(ns, sl, 0)
	end
lib/core/text/flat.nit:1534,2--1567,4