From 1da889f65a54190c8c9b687f0036637ab9a86701 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 9 Feb 2018 15:59:22 -0800 Subject: [PATCH] For now, switching back to __instances instead of HASH_BUCKETS, because it's cleaner and not *much* slower. --- limmutable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/limmutable.c b/limmutable.c index f4daee8..b257481 100644 --- a/limmutable.c +++ b/limmutable.c @@ -6,7 +6,6 @@ #include "lua.h" #include "lauxlib.h" -#define HASH_BUCKETS 1 #define MYNAME "immutable" #define MYTYPE MYNAME @@ -77,7 +76,7 @@ static int Lcreate_instance(lua_State *L) // Stack [inst] } - lua_rawgeti(L, 1, HASH_BUCKETS); + lua_getfield(L, 1, "__instances"); // Stack: [inst, buckets] // Find bucket @@ -184,7 +183,7 @@ static int Lindex(lua_State *L) lua_pop(L, 1); // All the slowness is concentrated here // Stack: [mt, fields, i] - lua_rawgeti(L, -3, HASH_BUCKETS); + lua_getfield(L, -3, "__instances"); // Stack: [mt, fields, i, buckets] lua_rawgeti(L, -1, *((lua_Integer*)lua_touserdata(L, 1))); // Stack: [mt, fields, i, buckets, bucket] @@ -243,7 +242,8 @@ static int Lmake_class(lua_State *L) // CLS.buckets = {} lua_newtable(L); // Stack: [CLS, CLS.buckets] - lua_rawseti(L, -2, HASH_BUCKETS); + lua_setfield(L, -2, "__instances"); + // Stack: [CLS] // CLS.__fields = arg1