Skip to content

Commit a6089b1

Browse files
authored
precompile restrict for Gray/RGB (#2)
1 parent d2197f6 commit a6089b1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/ImageUtils.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ using ImageCore.OffsetArrays
99
include("restrict.jl")
1010
include("compat.jl")
1111

12+
if VERSION >= v"1.4.2" # work around https://github.com/JuliaLang/julia/issues/34121
13+
include("precompile.jl")
14+
_precompile_()
15+
end
16+
1217
end

src/precompile.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
macro warnpcfail(ex::Expr)
2+
modl = __module__
3+
file = __source__.file === nothing ? "?" : String(__source__.file)
4+
line = __source__.line
5+
quote
6+
$(esc(ex)) || @warn """precompile directive
7+
$($(Expr(:quote, ex)))
8+
failed. Please report an issue in $($modl) (after checking for duplicates) or remove this directive.""" _file=$file _line=$line
9+
end
10+
end
11+
12+
function _precompile_()
13+
for ST in (N0f8, Float32, Float64)
14+
for T in (Gray{ST}, RGB{ST})
15+
@warnpcfail precompile(restrict, (Vector{T},))
16+
@warnpcfail precompile(restrict, (Matrix{T},))
17+
end
18+
end
19+
end # _precompile_

0 commit comments

Comments
 (0)