Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/abstractarray.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
length(a::SA) where {SA <: StaticArray} = prod(Size(SA))
length(a::Type{SA}) where {SA <: StaticArray} = prod(Size(SA))

size(::StaticArray{S}) where {S} = get(Size(S))
@pure size(::Type{<:StaticArray{S}}) where {S} = get(Size(S))

size(::SA, d::Int) where {SA <: StaticArray} = Size(SA)[d]
@pure size(::Type{SA}, d::Int) where {SA <: StaticArray} = Size(SA)[d]
@pure size(::Type{<:StaticArray{S}}) where S = tuple(S.parameters...)
@inline function size(t::Type{<:StaticArray}, d::Int)
S = size(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is generated code better with Size(t)?

d > length(S) ? 1 : S[d]
end
@inline size(a::StaticArray) = size(typeof(a))
@inline size(a::StaticArray, d::Int) = size(typeof(a), d)

# This seems to confuse Julia a bit in certain circumstances (specifically for trailing 1's)
@inline function Base.isassigned(a::StaticArray, i::Int...)
Expand Down