if type(opt) == 'string' then
opt,mtype = maybe_adjust_type(opt, mtype)
- local k = map_hash_key(opt, mtype)
- if maps_cache[k] then
+ local cache_key = map_hash_key(opt, mtype)
+ if maps_cache[cache_key] then
rspamd_logger.infox(rspamd_config, 'reuse url for %s(%s)',
opt, mtype)
- return maps_cache[k]
+ return maps_cache[cache_key]
end
-- We have a single string, so we treat it as a map
local map = rspamd_config:add_map{
if map then
ret.__data = map
- ret.hash = k
+ ret.hash = cache_key
setmetatable(ret, ret_mt)
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
end
elseif type(opt) == 'table' then
- local k = lua_util.table_digest(opt)
- if maps_cache[k] then
+ local cache_key = lua_util.table_digest(opt)
+ if maps_cache[cache_key] then
rspamd_logger.infox(rspamd_config, 'reuse url for complex map definition %s: %s',
- k:sub(1,8), description)
+ cache_key:sub(1,8), description)
- return maps_cache[k]
+ return maps_cache[cache_key]
end
if opt[1] then
if map then
ret.__data = map
setmetatable(ret, ret_mt)
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
end
else
if map then
ret.__data = map
setmetatable(ret, ret_mt)
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
end
end
if map then
ret.__data = map
setmetatable(ret, ret_mt)
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
end
else
if map then
ret.__data = map
setmetatable(ret, ret_mt)
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
end
end
if map then
ret.__data = map
setmetatable(ret, ret_mt)
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
end
else
-- Numeric table
if mtype == 'hash' then
-- Treat as KV pair
- local lua_util = require "lua_util"
local pieces = lua_util.str_split(elt, ' ')
if #pieces > 1 then
local key = table.remove(pieces, 1)
return nil
end
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
else
-- Empty map, huh?
if map then
ret.__data = map
setmetatable(ret, ret_mt)
- maps_cache[k] = ret
+ maps_cache[cache_key] = ret
return ret
end
end -- opt[1]