summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_noise.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_noise.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_noise.cpp')
-rw-r--r--src/script/lua_api/l_noise.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/script/lua_api/l_noise.cpp b/src/script/lua_api/l_noise.cpp
index e38d319f4..9aeb15709 100644
--- a/src/script/lua_api/l_noise.cpp
+++ b/src/script/lua_api/l_noise.cpp
@@ -171,9 +171,9 @@ int LuaPerlinNoiseMap::l_get_2d_map(lua_State *L)
Noise *n = o->noise;
n->perlinMap2D(p.X, p.Y);
- lua_newtable(L);
+ lua_createtable(L, n->sy, 0);
for (u32 y = 0; y != n->sy; y++) {
- lua_newtable(L);
+ lua_createtable(L, n->sx, 0);
for (u32 x = 0; x != n->sx; x++) {
lua_pushnumber(L, n->result[i++]);
lua_rawseti(L, -2, x + 1);
@@ -200,7 +200,7 @@ int LuaPerlinNoiseMap::l_get_2d_map_flat(lua_State *L)
if (use_buffer)
lua_pushvalue(L, 3);
else
- lua_newtable(L);
+ lua_createtable(L, maplen, 0);
for (size_t i = 0; i != maplen; i++) {
lua_pushnumber(L, n->result[i]);
@@ -224,11 +224,11 @@ int LuaPerlinNoiseMap::l_get_3d_map(lua_State *L)
Noise *n = o->noise;
n->perlinMap3D(p.X, p.Y, p.Z);
- lua_newtable(L);
+ lua_createtable(L, n->sz, 0);
for (u32 z = 0; z != n->sz; z++) {
- lua_newtable(L);
+ lua_createtable(L, n->sy, 0);
for (u32 y = 0; y != n->sy; y++) {
- lua_newtable(L);
+ lua_createtable(L, n->sx, 0);
for (u32 x = 0; x != n->sx; x++) {
lua_pushnumber(L, n->result[i++]);
lua_rawseti(L, -2, x + 1);
@@ -260,7 +260,7 @@ int LuaPerlinNoiseMap::l_get_3d_map_flat(lua_State *L)
if (use_buffer)
lua_pushvalue(L, 3);
else
- lua_newtable(L);
+ lua_createtable(L, maplen, 0);
for (size_t i = 0; i != maplen; i++) {
lua_pushnumber(L, n->result[i]);