mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-23 20:55:09 +00:00
Move mcl_util.hash to a local function
It is probably unlikely it will be useful at other places in Mineclone2.
This commit is contained in:
parent
e32f17b82a
commit
3308ce812d
2 changed files with 9 additions and 9 deletions
|
@ -405,11 +405,3 @@ function mcl_util.get_object_center(obj)
|
|||
pos.y = pos.y + (ymax - ymin) / 2.0
|
||||
return pos
|
||||
end
|
||||
|
||||
-- Compute a hash value.
|
||||
function mcl_util.hash(value)
|
||||
-- minetest.get_password_hash is quite fast, even if it uses a
|
||||
-- cryptographic hashing function (SHA-1). It is written in C++ and it
|
||||
-- is probably hard to write a faster hashing function in Lua.
|
||||
return string.sub(minetest.get_password_hash("ryvnf", minetest.serialize(value)), 1, 8)
|
||||
end
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
local efficiency_cache_table = {}
|
||||
|
||||
-- Compute a hash value.
|
||||
function compute_hash(value)
|
||||
-- minetest.get_password_hash is quite fast, even if it uses a
|
||||
-- cryptographic hashing function (SHA-1). It is written in C++ and it
|
||||
-- is probably hard to write a faster hashing function in Lua.
|
||||
return string.sub(minetest.get_password_hash("ryvnf", minetest.serialize(value)), 1, 8)
|
||||
end
|
||||
|
||||
-- Get the efficiency groupcaps and hash for a tool and efficiency level. If
|
||||
-- this function is called repeatedly with the same values it will return data
|
||||
-- from a cache.
|
||||
|
@ -18,7 +26,7 @@ local function get_efficiency_groupcaps(toolname, level)
|
|||
if not levelcache then
|
||||
levelcache = {}
|
||||
levelcache.values = mcl_autogroup.get_groupcaps(toolname, level)
|
||||
levelcache.hash = mcl_util.hash(levelcache.values)
|
||||
levelcache.hash = compute_hash(levelcache.values)
|
||||
toolcache[level] = levelcache
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue