For now, switching back to __instances instead of HASH_BUCKETS, because
it's cleaner and not *much* slower.
This commit is contained in:
parent
5c8d0fd69a
commit
1da889f65a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user