From b22a76d24f2f3e2d9b1a2f85ed61d455dd788fe0 Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Mon, 16 Aug 2021 18:39:32 -0400 Subject: [PATCH 1/2] Stop recursing when the eltype is not mutable --- src/utils.jl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 0b1baf57..2e6f9677 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -31,9 +31,14 @@ function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<: end function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<:AbstractArray,T2<:AbstractArray,N} - @inbounds for i in eachindex(a) - recursivecopy!(b[i],a[i]) + if ArrayInterface.ismutable(T) + @inbounds for i in eachindex(a) + recursivecopy!(b[i], a[i]) + end + else + copyto!(b, a) end + return b end function vecvec_to_mat(vecvec) From c6a0fcab1c32a44e923f657b01ff2b1a8c236c60 Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Mon, 16 Aug 2021 19:24:06 -0400 Subject: [PATCH 2/2] Update src/utils.jl --- src/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index 2e6f9677..c4487140 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -32,7 +32,7 @@ end function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<:AbstractArray,T2<:AbstractArray,N} if ArrayInterface.ismutable(T) - @inbounds for i in eachindex(a) + @inbounds for i in eachindex(b, a) recursivecopy!(b[i], a[i]) end else