optimize copyFilters/mergeFilters

This commit is contained in:
Tom van Dijck 2016-04-11 11:20:54 -07:00
parent 002e65d428
commit 29f588fdc9

View File

@ -94,7 +94,10 @@
-- --
function context.copyFilters(ctx, src) function context.copyFilters(ctx, src)
ctx.terms = table.deepcopy(src.terms) ctx.terms = {}
for k,v in pairs(src.terms) do
ctx.terms[k] = v
end
end end
@ -109,22 +112,9 @@
-- --
function context.mergeFilters(ctx, src) function context.mergeFilters(ctx, src)
for k,v in pairs(src.terms) do
local function mergeTable(dest, src) ctx.terms[k] = v
for k,v in pairs(src) do
if type(v) == "table" then
if type(dest[k]) == "table" then
dest[k] = mergeTable(dest[k], v)
else
dest[k] = table.deepcopy(v)
end
else
dest[k] = v
end
end
end end
mergeTable(ctx.terms, src.terms)
end end