diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-11 11:07:58 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-11 11:07:58 +0100 |
commit | 09551bcf6ad0033e5e56e53b9d2e7b05d4d91996 (patch) | |
tree | 31284f84ec39c68c672ffb8ddf4f9a205573bd02 /lualib/lua_util.lua | |
parent | 2ee5f7e4cdadb324aa16af67491f56a1f6fdb412 (diff) | |
parent | 36aac959a763a1fdd82b9056b43962d4ea898e38 (diff) | |
download | rspamd-09551bcf6ad0033e5e56e53b9d2e7b05d4d91996.tar.gz rspamd-09551bcf6ad0033e5e56e53b9d2e7b05d4d91996.zip |
Merge branch 'master' into redis-coroutines
Diffstat (limited to 'lualib/lua_util.lua')
-rw-r--r-- | lualib/lua_util.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua index b8e1dbfad..4b18d854c 100644 --- a/lualib/lua_util.lua +++ b/lualib/lua_util.lua @@ -688,6 +688,24 @@ end exports.deepcopy = deepcopy +--[[[ +-- @function lua_util.shallowcopy(tbl) +-- Performs shallow (and fast) copy of a table or another Lua type +--]] +exports.shallowcopy = function(orig) + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in pairs(orig) do + copy[orig_key] = orig_value + end + else + copy = orig + end + return copy +end + -- Debugging support local unconditional_debug = false local debug_modules = {} @@ -721,4 +739,5 @@ exports.debugm = function(mod, ...) end end + return exports |