Skip to content

Commit 26ae93f

Browse files
committed
Reduce compilation of Base methods (NFC)
This is motivated by JuliaLang/julia#43990 (comment), but doesn't seem likely to hurt anything even if that never merges.
1 parent 79226fa commit 26ae93f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/toplevel_generators.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
133133
# Helper function to parse triplets for us
134134
$(platform_parse_compat())
135135
function make_wrapper_dict(dir, x)
136-
return Dict(
137-
parse_wrapper_platform(basename(f)[1:end-3]) =>
138-
joinpath(dir, "wrappers", f) for f in x
139-
)
136+
# (1) make the Dict type inferrable
137+
# (2) avoid creation of Generators so that we don't have to compile
138+
# package-specific Generator-closures
139+
d = Dict{Platform,String}()
140+
for f in x
141+
d[parse_wrapper_platform(basename(f)[1:end-3])] = joinpath(dir, "wrappers", f)
142+
end
143+
return d
140144
end
141145

142146
# If it's a Dict, that means this is an AnyPlatform artifact, act accordingly:
@@ -145,7 +149,10 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
145149
else
146150
# Otherwise, it's a Vector, and we must select the best platform
147151
# First, find all wrappers on-disk, parse their platforms, and match:
148-
wrapper_files = filter(x -> endswith(x, ".jl"), readdir(joinpath($(pkg_dir), "wrappers")))
152+
wrapper_files = String[]
153+
for x in readdir(joinpath($(pkg_dir), "wrappers"))
154+
endswith(x, ".jl") && push!(wrapper_files, x) # avoid creation of Generators...
155+
end
149156
wrappers = make_wrapper_dict($(pkg_dir), wrapper_files)
150157
for e in artifacts
151158
platform = unpack_platform(e, $(jll_name), artifacts_toml)

0 commit comments

Comments
 (0)