mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +01: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
2e9b3c2259
commit
6458565bf9
@ -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 New Issue
Block a user