Merge pull request #471 from Blizzard/optimize-copy-merge-filters

optimize copyFilters/mergeFilters
This commit is contained in:
Jason Perkins 2016-04-12 06:25:36 -04:00
commit 870d21f382

View File

@ -94,7 +94,10 @@
--
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
@ -109,22 +112,9 @@
--
function context.mergeFilters(ctx, src)
local function mergeTable(dest, src)
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
for k,v in pairs(src.terms) do
ctx.terms[k] = v
end
mergeTable(ctx.terms, src.terms)
end