Skip to content

Commit 9824a94

Browse files
cleanup copyat_or_push
1 parent 5f22f9e commit 9824a94

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/utils.jl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,20 @@ end
7272
recursivecopy!(a[i],x)
7373
end
7474
else
75-
if eltype(x) <: Number && (typeof(x) <: Array || typeof(x) <: Number)
76-
# Have to check that it's <: Array or can have problems
77-
# with abstract arrays like MultiScaleModels.
78-
# Have to check <: Number since it could just be a number...
7975
if perform_copy
80-
push!(a,copy(x))
81-
else
82-
push!(a,x)
83-
end
84-
else
85-
if perform_copy
86-
if typeof(x) <: Vector && !(eltype(x) <: Number)
76+
if typeof(x) <: Array && !(eltype(x) <: Number)
8777
push!(a,recursivecopy(x))
88-
elseif typeof(x) <: ArrayPartition || typeof(x) <: AbstractVectorOfArray
78+
elseif typeof(x) <: Array || typeof(x) <: ArrayPartition ||
79+
typeof(x) <: AbstractVectorOfArray
8980
push!(a,copy(x))
90-
elseif typeof(x) <: SArray
81+
elseif typeof(x) <: Union{SVector,SMatrix,SArray,Number} # Only immutable
9182
push!(a,x)
9283
else
9384
push!(a,deepcopy(x))
9485
end
9586
else
9687
push!(a,x)
9788
end
98-
end
9989
end
10090
nothing
10191
end

0 commit comments

Comments
 (0)