From d57683f5f67d6651f7b3353ff347ae57a409e0d4 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 16 Apr 2018 13:13:20 +0200 Subject: 2018-04-16 12:13:00 --- tex/context/base/mkiv/mlib-lua.lua | 47 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'tex/context/base/mkiv/mlib-lua.lua') 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() -- cgit v1.2.3