Skip to content

Commit

Permalink
Merge pull request #46 from JuliaCollections/feature/memoize-dict-in-…
Browse files Browse the repository at this point in the history
…Main

Use Main instead of `@__MODULE__` to hold memoization Dict
  • Loading branch information
kmsquire authored Feb 19, 2020
2 parents 0e48ecf + c4d39de commit 1709785
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Memoize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ macro memoize(args...)
end

fcachename = Symbol("##", f, "_memoized_cache")
mod = @__MODULE__
fcache = isdefined(mod, fcachename) ?
getfield(mod, fcachename) :
Core.eval(mod, :(const $fcachename = ($dicttype)()))
fcache = isdefined(Main, fcachename) ?
getfield(Main, fcachename) :
Core.eval(Main, :(const $fcachename = ($dicttype)()))

if length(kws) == 0
lookup = :($fcache[($(tup...),)]::Core.Compiler.return_type($u, typeof(($(identargs...),))))
Expand Down

0 comments on commit 1709785

Please sign in to comment.