From 1de7c5bdfda40e81aa7786ce4856233c1c9a3a52 Mon Sep 17 00:00:00 2001 From: Dohyun Kim Date: Sun, 29 Dec 2013 14:46:00 +0900 Subject: reduce the size of res table --- luaotfload-colors.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/luaotfload-colors.lua b/luaotfload-colors.lua index 3b430f3..b8ecb87 100644 --- a/luaotfload-colors.lua +++ b/luaotfload-colors.lua @@ -126,12 +126,12 @@ registerotffeature { --- something is carried around in ``res`` --- for later use by color_handler() --- but what? -local res = {} +local res = nil --- float -> unit local function pageresources(alpha) - res[#res+1] = stringformat("/TransGs%s<>", - alpha, alpha, alpha) + res = res or {} + res[alpha] = true end --- we store results of below color handler as tuples of @@ -275,13 +275,13 @@ end local color_handler = function (head) local new_head = node_colorize(head, nil, nil) -- now append our page resources - if res and #res > 0 then + if res then + res["1"] = true local tpr, t = tex.pdfpageresources, "" - res[#res+1] = "/TransGs1<>" - for i = 1,#res do - if stringfind(tpr,res[i]) or stringfind(t,res[i]) then - else - t = t .. res[i] + for k in pairs(res) do + local str = stringformat("/TransGs%s<>", k, k, k) + if not stringfind(tpr,str) then + t = t .. str end end if t ~= "" then @@ -291,7 +291,7 @@ local color_handler = function (head) tpr = stringgsub(tpr,"/ExtGState<<","%1"..t) tex.pdfpageresources = tpr end - res = {} -- reset res + res = nil -- reset res end return new_head end -- cgit v1.2.3