diff options
author | orwell96 <mono96.mml@gmail.com> | 2017-01-31 20:52:02 +0100 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2017-01-31 20:52:02 +0100 |
commit | 78e936bea7831e9a0d253b72ca8a63da558c9e81 (patch) | |
tree | bf4507380289315b33f1116cde542801d5a0f548 /advtrains/advtrains/tracks.lua | |
parent | 01f0d2c44559fd30c81d69707324bd0e9e4742c0 (diff) | |
download | advtrains-78e936bea7831e9a0d253b72ca8a63da558c9e81.tar.gz advtrains-78e936bea7831e9a0d253b72ca8a63da558c9e81.tar.bz2 advtrains-78e936bea7831e9a0d253b72ca8a63da558c9e81.zip |
Replace all table indices that were pos_to_string strings with node hashes.
Lua table string lookup consumes about 10 times more time than numeric indices
Diffstat (limited to 'advtrains/advtrains/tracks.lua')
-rw-r--r-- | advtrains/advtrains/tracks.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index a44acb3..2c5c121 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -389,19 +389,19 @@ advtrains.detector.on_node = {} function advtrains.detector.enter_node(pos, train_id)
local ppos=advtrains.round_vector_floor_y(pos)
- local pts=minetest.pos_to_string(ppos)
+ local pts=minetest.hash_node_position(ppos)
advtrains.detector.on_node[pts]=train_id
advtrains.detector.call_enter_callback(ppos, train_id)
end
function advtrains.detector.leave_node(pos, train_id)
local ppos=advtrains.round_vector_floor_y(pos)
- local pts=minetest.pos_to_string(ppos)
+ local pts=minetest.hash_node_position(ppos)
advtrains.detector.on_node[pts]=nil
advtrains.detector.call_leave_callback(ppos, train_id)
end
function advtrains.detector.stay_node(pos, train_id)
local ppos=advtrains.round_vector_floor_y(pos)
- local pts=minetest.pos_to_string(ppos)
+ local pts=minetest.hash_node_position(ppos)
advtrains.detector.on_node[pts]=train_id
end
|