Skip to content

Commit 7cc7f9d

Browse files
authored
Merge pull request #307 from tkoolen/noinline-conversion-dimension-mismatch
Speed up conversion to StaticArray
2 parents b078b3f + 4dbc2bd commit 7cc7f9d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/convert.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
unroll_tuple(a, Length(a))
1414
end
1515

16+
@noinline function dimension_mismatch_fail(SA::Type, a::AbstractArray)
17+
error("Dimension mismatch. Expected input array of length $(length(SA)), got length $(length(a))")
18+
end
19+
1620
@inline function convert(::Type{SA}, a::AbstractArray) where {SA <: StaticArray}
1721
@boundscheck if length(a) != length(SA)
18-
error("Dimension mismatch. Expected input array of length $(length(SA)), got length $(length(a))")
22+
dimension_mismatch_fail(SA, a)
1923
end
2024

2125
return SA(unroll_tuple(a, Length(SA)))

0 commit comments

Comments
 (0)