diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-04-16 13:13:20 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-04-16 13:13:20 +0200 |
commit | d57683f5f67d6651f7b3353ff347ae57a409e0d4 (patch) | |
tree | 1ffc5bda90e3eedad0a35eaa8937472f5563c796 /tex/context/base/mkiv/mlib-lua.lua | |
parent | d5d5a39dc16881d098a99b74cba9020d96be4e11 (diff) | |
download | context-d57683f5f67d6651f7b3353ff347ae57a409e0d4.tar.gz |
2018-04-16 12:13:00
Diffstat (limited to 'tex/context/base/mkiv/mlib-lua.lua')
-rw-r--r-- | tex/context/base/mkiv/mlib-lua.lua | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua index d934e6472..189f207c7 100644 --- a/tex/context/base/mkiv/mlib-lua.lua +++ b/tex/context/base/mkiv/mlib-lua.lua @@ -359,35 +359,36 @@ end -- endfor ; -- \stopMPpage -local cache, n = { }, 0 -- todo: when > n then reset cache or make weak +local runs = 0 + +function metapost.nofscriptruns() + return runs +end + +-- local cache = table.makeweak() +-- +-- f = cache[code] +-- if not f then +-- f = loadstring(f_code(code)) +-- if f then +-- cache[code] = f +-- elseif be_tolerant then +-- f = loadstring(code) +-- if f then +-- cache[code] = f +-- end +-- end +-- end function metapost.runscript(code) local trace = trace_enabled and trace_luarun if trace then report_luarun("code: %s",code) end - local f - if n > 100 then - cache = nil -- forget about caching - f = loadstring(f_code(code)) - if not f and be_tolerant then - f = loadstring(code) - end - else - f = cache[code] - if not f then - f = loadstring(f_code(code)) - if f then - n = n + 1 - cache[code] = f - elseif be_tolerant then - f = loadstring(code) - if f then - n = n + 1 - cache[code] = f - end - end - end + runs = runs + 1 + local f = loadstring(f_code(code)) + if not f and be_tolerant then + f = loadstring(code) end if f then local result = f() |