@@ -112,15 +112,15 @@ end
112
112
end
113
113
end
114
114
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)
117
117
end
118
118
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) ]
121
121
return quote
122
122
@_propagate_inbounds_meta
123
- similar_type (a, Size (L) )(tuple ($ (exprs... )))
123
+ similar_type (a, s )(tuple ($ (exprs... )))
124
124
end
125
125
end
126
126
@@ -159,36 +159,36 @@ end
159
159
end
160
160
end
161
161
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)
164
164
return v
165
165
end
166
166
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) ]
169
169
return quote
170
170
@_propagate_inbounds_meta
171
- similar_type (a, Size (L) )(tuple ($ (exprs... )))
171
+ similar_type (a, s )(tuple ($ (exprs... )))
172
172
end
173
173
end
174
174
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) ]
177
177
return quote
178
178
@_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" ))
181
181
end
182
182
$ (Expr (:block , exprs... ))
183
183
end
184
184
end
185
185
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) ]
188
188
return quote
189
189
@_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" ))
192
192
end
193
193
$ (Expr (:block , exprs... ))
194
194
end
0 commit comments