Skip to content

Commit 4dbc2bd

Browse files
committed
Speed up convert(::Type{SA}, a::AbstractArray)
Use `@noinline` trick (see e.g. JuliaLang/julia#23088 (comment)) to speed up convert(::Type{SA}, a::AbstractArray).
1 parent 0bbc0e3 commit 4dbc2bd

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)