Consider the current implementation of a particular instance of vcat in
abstractarray.jl, line 518:
function vcat(X::Number...)
T = None
for x in X
T = promote_type(T,typeof(x))
end
hvcat_fill(Array(T,length(X)), X)
end
Is there a specific reason why an implementation like this was not chosen?
function vcat(X::Number...)
T = promote_type(map(typeof,X))
hvcat_fill(Array(T,length(X)), X)
end
In addition, consider the implementation of hvcat_fill, same file, line 827:
function hvcat_fill(a, xs)
k = 1
nr, nc = size(a,1), size(a,2)
for i=1:nr
@inbounds for j=1:nc
a[i,j] = xs[k]
k += 1
end
end
a
end
For the *specific *usage above, is there any reason not to prefer this:
function hvcat_fill(a, xs)
@inbounds for j=1:length(a)
a[j] = xs[j]
end
a
end
This function is used in three different places; in each case, the array is
indeed contiguous.