From 29f588fdc95ba0b86712e2b17b02af07db14a3ad Mon Sep 17 00:00:00 2001 From: Tom van Dijck Date: Mon, 11 Apr 2016 11:20:54 -0700 Subject: [PATCH] optimize copyFilters/mergeFilters --- src/base/context.lua | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/base/context.lua b/src/base/context.lua index 094a223e..37861e02 100644 --- a/src/base/context.lua +++ b/src/base/context.lua @@ -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