@@ -112,15 +112,15 @@ end
112112 end
113113end
114114
115- @propagate_inbounds function getindex (a:: StaticArray , inds:: StaticVector {<:Any , Int} )
116- _getindex (a, Length (inds), inds)
115+ @propagate_inbounds function getindex (a:: StaticArray , inds:: StaticArray {<:Tuple , Int} )
116+ _getindex (a, Size (inds), inds)
117117end
118118
119- @generated function _getindex (a:: StaticArray , :: Length{L } , inds:: StaticVector {<:Any , Int} ) where {L }
120- exprs = [:(a[inds[$ i]]) for i = 1 : L ]
119+ @generated function _getindex (a:: StaticArray , s :: Size{S } , inds:: StaticArray {<:Tuple , Int} ) where {S }
120+ exprs = [:(a[inds[$ i]]) for i = 1 : prod (S) ]
121121 return quote
122122 @_propagate_inbounds_meta
123- similar_type (a, Size (L) )(tuple ($ (exprs... )))
123+ similar_type (a, s )(tuple ($ (exprs... )))
124124 end
125125end
126126
@@ -159,36 +159,36 @@ end
159159 end
160160end
161161
162- @propagate_inbounds function setindex! (a:: StaticArray , v, inds:: StaticVector {<:Any , Int} )
163- _setindex! (a, v, Length (inds), inds)
162+ @propagate_inbounds function setindex! (a:: StaticArray , v, inds:: StaticArray {<:Tuple , Int} )
163+ _setindex! (a, v, Size (inds), inds)
164164 return v
165165end
166166
167- @generated function _setindex! (a:: StaticArray , v, :: Length{L } , inds:: StaticVector {<:Any , Int} ) where {L }
168- exprs = [:(a[inds[$ i]] = v) for i = 1 : L ]
167+ @generated function _setindex! (a:: StaticArray , v, s :: Size{S } , inds:: StaticArray {<:Tuple , Int} ) where {S }
168+ exprs = [:(a[inds[$ i]] = v) for i = 1 : prod (S) ]
169169 return quote
170170 @_propagate_inbounds_meta
171- similar_type (a, Size (L) )(tuple ($ (exprs... )))
171+ similar_type (a, s )(tuple ($ (exprs... )))
172172 end
173173end
174174
175- @generated function _setindex! (a:: StaticArray , v:: AbstractArray , :: Length{L } , inds:: StaticVector {<:Any , Int} ) where {L }
176- exprs = [:(a[inds[$ i]] = v[$ i]) for i = 1 : L ]
175+ @generated function _setindex! (a:: StaticArray , v:: AbstractArray , s :: Size{S } , inds:: StaticArray {<:Tuple , Int} ) where {S }
176+ exprs = [:(a[inds[$ i]] = v[$ i]) for i = 1 : prod (S) ]
177177 return quote
178178 @_propagate_inbounds_meta
179- if length (v) != L
180- throw (DimensionMismatch (" tried to assign $(length (v)) -element array to length-$L destination" ))
179+ if length (v) != $ ( prod (S))
180+ throw (DimensionMismatch (" tried to assign $(length (v)) -element array to length-$( length (inds)) destination" ))
181181 end
182182 $ (Expr (:block , exprs... ))
183183 end
184184end
185185
186- @generated function _setindex! (a:: StaticArray , v:: StaticArray , :: Length{L } , inds:: StaticVector {<:Any , Int} ) where {L }
187- exprs = [:(a[inds[$ i]] = v[$ i]) for i = 1 : L ]
186+ @generated function _setindex! (a:: StaticArray , v:: StaticArray , s :: Size{S } , inds:: StaticArray {<:Tuple , Int} ) where {S }
187+ exprs = [:(a[inds[$ i]] = v[$ i]) for i = 1 : prod (S) ]
188188 return quote
189189 @_propagate_inbounds_meta
190- if Length (typeof (v)) != L
191- throw (DimensionMismatch (" tried to assign $(length (v)) -element array to length-$L destination" ))
190+ if Length (typeof (v)) != Length (s)
191+ throw (DimensionMismatch (" tried to assign $(length (v)) -element array to length-$( length (inds)) destination" ))
192192 end
193193 $ (Expr (:block , exprs... ))
194194 end
0 commit comments