Skip to content

Commit dd3c53a

Browse files
committed
move shuffling of animals to be done on demand instead of during initialization
1 parent 65c5553 commit dd3c53a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/MacroTools.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@ _animals = split(read(animals_file, String))
2323
resize!(animals, length(_animals))
2424
animals .= Symbol.(lowercase.(_animals))
2525

26-
function __init__()
27-
Random.shuffle!(animals)
28-
end
2926

3027
end # module

src/utils.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ function gensym_ids(ex)
190190
end
191191
end
192192

193+
const l = ReentrantLock()
194+
const shuffled = Ref{Bool}(false)
195+
193196
"""
194197
alias_gensyms(expr)
195198
@@ -205,6 +208,12 @@ julia> MacroTools.alias_gensyms(:(\$x+\$y))
205208
```
206209
"""
207210
function alias_gensyms(ex)
211+
lock(l) do
212+
if !shuffled[]
213+
Random.shuffle!(animals)
214+
shuffled[] = true
215+
end
216+
end
208217
left = copy(animals)
209218
syms = Dict{Symbol, Symbol}()
210219
prewalk(ex) do x

0 commit comments

Comments
 (0)