Skip to content

Commit e530f2f

Browse files
authored
Faster collect (#312)
1 parent 287c6c6 commit e530f2f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/sparsevector.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,14 @@ function Vector(x::AbstractSparseVector{Tv}) where Tv
10641064
return r
10651065
end
10661066
Array(x::AbstractSparseVector) = Vector(x)
1067+
1068+
function Base.collect(x::Union{AbstractSparseVector,AbstractSparseMatrix})
1069+
if Base.has_offset_axes(x)
1070+
return Base._collect_indices(axes(x), x)
1071+
else
1072+
return Array(x)
1073+
end
1074+
end
10671075

10681076
Base.iszero(x::AbstractSparseVector) = iszero(nonzeros(x))
10691077

0 commit comments

Comments
 (0)