From 9928aedcd4d73430b91809930ee4685e2cdbf5aa Mon Sep 17 00:00:00 2001 From: Carlo Baldassi Date: Fri, 25 Oct 2013 03:42:26 +0200 Subject: [PATCH 1/2] Fix append!(x,x) and prepend!(x,x) --- base/array.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/array.jl b/base/array.jl index b20fe0f8d17e6..db1288cd3b0a1 100644 --- a/base/array.jl +++ b/base/array.jl @@ -673,6 +673,7 @@ function append!{T}(a::Array{T,1}, items::Vector) error(_grow_none_errmsg) end n = length(items) + a === items && (items = copy(items)) ccall(:jl_array_grow_end, Void, (Any, Uint), a, n) a[end-n+1:end] = items return a @@ -683,6 +684,7 @@ function prepend!{T}(a::Array{T,1}, items::Array{T,1}) error(_grow_none_errmsg) end n = length(items) + a === items && (items = copy(items)) ccall(:jl_array_grow_beg, Void, (Any, Uint), a, n) a[1:n] = items return a From a72b1ff7352a9084eb7bba29fffb38b92189f1f9 Mon Sep 17 00:00:00 2001 From: Carlo Baldassi Date: Fri, 25 Oct 2013 03:43:40 +0200 Subject: [PATCH 2/2] Allow {ap,pre}pending AbstractVectors to Arrays --- base/array.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/array.jl b/base/array.jl index db1288cd3b0a1..7bf843742a7ca 100644 --- a/base/array.jl +++ b/base/array.jl @@ -668,7 +668,7 @@ function push!(a::Array{Any,1}, item::ANY) return a end -function append!{T}(a::Array{T,1}, items::Vector) +function append!{T}(a::Array{T,1}, items::AbstractVector) if is(T,None) error(_grow_none_errmsg) end @@ -679,7 +679,7 @@ function append!{T}(a::Array{T,1}, items::Vector) return a end -function prepend!{T}(a::Array{T,1}, items::Array{T,1}) +function prepend!{T}(a::Array{T,1}, items::AbstractVector) if is(T,None) error(_grow_none_errmsg) end