Skip to content

Commit 6f123e8

Browse files
authored
inference + allocation in fix_kinds (#254)
* inference + allocation in fix_kinds * copyto! and any in fix_kinds
1 parent 17bc81a commit 6f123e8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/fft.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -563,19 +563,17 @@ function fix_kinds(region, kinds)
563563
throw(ArgumentError("must supply a transform kind"))
564564
end
565565
k = Vector{Int32}(undef, length(region))
566-
k[1:length(kinds)] = [kinds...]
566+
copyto!(k, kinds)
567567
k[length(kinds)+1:end] .= kinds[end]
568-
kinds = k
569568
end
570569
else
571-
kinds = Int32[kinds...]
570+
k = Vector{Int32}(undef, length(kinds))
571+
k .= kinds
572572
end
573-
for i = 1:length(kinds)
574-
if kinds[i] < 0 || kinds[i] > 10
575-
throw(ArgumentError("invalid transform kind"))
576-
end
573+
if any(x -> x < 0 || x > 10, k)
574+
throw(ArgumentError("invalid transform kind"))
577575
end
578-
return kinds
576+
return k
579577
end
580578

581579
# low-level FFTWPlan creation (for internal use in FFTW module)

0 commit comments

Comments
 (0)