summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-04-14 20:44:18 +0200
committerGitHub <noreply@github.com>2020-04-14 20:44:18 +0200
commit2d5bd3bf794672285cfc796edebab2f672f2cab0 (patch)
treef4922fa8689156f33e9e37c32163cb719bd390e2 /src/script/lua_api/l_env.cpp
parent7c43cf47c37b0204e34d12670d2e6975eb36b45a (diff)
downloadminetest-2d5bd3bf794672285cfc796edebab2f672f2cab0.tar.gz
minetest-2d5bd3bf794672285cfc796edebab2f672f2cab0.tar.bz2
minetest-2d5bd3bf794672285cfc796edebab2f672f2cab0.zip
scriptapi: Some small optimizations to value pushing (#9669)
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r--src/script/lua_api/l_env.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index e3afe1862..8c45a1510 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -73,7 +73,7 @@ void LuaABM::trigger(ServerEnvironment *env, v3s16 p, MapNode n,
lua_remove(L, -2); // Remove core
// Get registered_abms[m_id]
- lua_pushnumber(L, m_id);
+ lua_pushinteger(L, m_id);
lua_gettable(L, -2);
if(lua_isnil(L, -1))
FATAL_ERROR("");
@@ -116,7 +116,7 @@ void LuaLBM::trigger(ServerEnvironment *env, v3s16 p, MapNode n)
lua_remove(L, -2); // Remove core
// Get registered_lbms[m_id]
- lua_pushnumber(L, m_id);
+ lua_pushinteger(L, m_id);
lua_gettable(L, -2);
FATAL_ERROR_IF(lua_isnil(L, -1), "Entry with given id not found in registered_lbms table");
lua_remove(L, -2); // Remove registered_lbms
@@ -550,7 +550,7 @@ int ModApiEnvMod::l_find_nodes_with_meta(lua_State *L)
std::vector<v3s16> positions = env->getMap().findNodesWithMetadata(
check_v3s16(L, 1), check_v3s16(L, 2));
- lua_newtable(L);
+ lua_createtable(L, positions.size(), 0);
for (size_t i = 0; i != positions.size(); i++) {
push_v3s16(L, positions[i]);
lua_rawseti(L, -2, i + 1);
@@ -1197,7 +1197,7 @@ int ModApiEnvMod::l_find_path(lua_State *L)
searchdistance, max_jump, max_drop, algo);
if (!path.empty()) {
- lua_newtable(L);
+ lua_createtable(L, path.size(), 0);
int top = lua_gettop(L);
unsigned int index = 1;
for (const v3s16 &i : path) {