diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-nut.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/node-nut.lua | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-nut.lua b/Master/texmf-dist/tex/context/base/node-nut.lua index 2b4e9968c6e..32f2d57ec32 100644 --- a/Master/texmf-dist/tex/context/base/node-nut.lua +++ b/Master/texmf-dist/tex/context/base/node-nut.lua @@ -86,10 +86,14 @@ if not modules then modules = { } end modules ['node-met'] = { -- luatex 3.9 sec / 54 pps -- luajittex 2.3 sec / 93 pps +local type, rawget = type, rawget + local nodes = nodes local gonuts = nodes.gonuts local direct = node.direct +local fastcopy = table.fastcopy + if type(direct) ~= "table" then return elseif gonuts then @@ -136,6 +140,20 @@ nuts.getsubtype = direct.getsubtype nuts.getlist = direct.getlist -- only hlist and vlist ! nuts.getleader = direct.getleader +-- local function track(name) +-- local n = 0 +-- local f = nuts[name] +-- function nuts[name](...) +-- n = n + 1 +-- if n % 1000 == 0 then +-- print(name,n) +-- end +-- return f(...) +-- end +-- end + +-- track("getsubtype") + -- local dgf = direct.getfield function nuts.getlist(n) return dgf(n,"list") end -- setters @@ -662,8 +680,14 @@ if propertydata then data = propertydata, } - direct.set_properties_mode(true,false) - -- direct.set_properties_mode(true,true) + -- direct.set_properties_mode(true,false) -- shallow copy ... problem: in fonts we then affect the originals too + direct.set_properties_mode(true,true) -- create metatable, slower but needed for font-inj.lua (unless we use an intermediate table) + + -- todo: + -- + -- function direct.set_properties_mode() + -- -- we really need the set modes + -- end -- experimental code with respect to copying attributes has been removed -- as it doesn't pay of (most attributes are only accessed once anyway) @@ -700,3 +724,31 @@ else nodes.getprop = setattr end + +function nuts.copy_properties(source,target,what) + local newprops = propertydata[source] + if not newprops then + -- nothing to copy + return + end + if what then + -- copy one category + newprops = rawget(source,what) + if newprops then + newprops = fastcopy(newprops) + local p = rawget(propertydata,target) + if p then + p[what] = newprops + else + propertydata[target] = { + [what] = newprops, + } + end + end + else + -- copy all properties + newprops = fastcopy(newprops) + propertydata[target] = newprops + end + return newprops -- for checking +end |