Use binary search for all Lua cobject fields
This commit is contained in:
parent
5cfef9abb3
commit
0d29a29c1b
|
@ -37,13 +37,7 @@ $[INCLUDES]
|
|||
$[BODY]
|
||||
struct LuaObjectField* smlua_get_object_field_autogen(u16 lot, const char* key) {
|
||||
struct LuaObjectTable* ot = &sLuaObjectAutogenTable[lot - LOT_AUTOGEN_MIN - 1];
|
||||
// TODO: change this to binary search or hash table or something
|
||||
for (int i = 0; i < ot->fieldCount; i++) {
|
||||
if (!strcmp(ot->fields[i].key, key)) {
|
||||
return &ot->fields[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return smlua_get_object_field_from_ot(ot, key);
|
||||
}
|
||||
|
||||
"""
|
||||
|
|
|
@ -33,13 +33,7 @@ struct LuaObjectTable sLuaObjectTable[LOT_MAX] = {
|
|||
{ LOT_VEC3F, sVec3fFields, LUA_VEC3F_FIELD_COUNT },
|
||||
};
|
||||
|
||||
struct LuaObjectField* smlua_get_object_field(u16 lot, const char* key) {
|
||||
if (lot > LOT_AUTOGEN_MIN) {
|
||||
return smlua_get_object_field_autogen(lot, key);
|
||||
}
|
||||
|
||||
struct LuaObjectTable* ot = &sLuaObjectTable[lot];
|
||||
|
||||
struct LuaObjectField* smlua_get_object_field_from_ot(struct LuaObjectTable* ot, const char* key) {
|
||||
// binary search
|
||||
s32 min = 0;
|
||||
s32 max = ot->fieldCount - 1;
|
||||
|
@ -64,6 +58,15 @@ struct LuaObjectField* smlua_get_object_field(u16 lot, const char* key) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct LuaObjectField* smlua_get_object_field(u16 lot, const char* key) {
|
||||
if (lot > LOT_AUTOGEN_MIN) {
|
||||
return smlua_get_object_field_autogen(lot, key);
|
||||
}
|
||||
|
||||
struct LuaObjectTable* ot = &sLuaObjectTable[lot];
|
||||
return smlua_get_object_field_from_ot(ot, key);
|
||||
}
|
||||
|
||||
bool smlua_valid_lot(u16 lot) {
|
||||
if (lot > LOT_NONE && lot < LOT_MAX) { return true; }
|
||||
if (lot > LOT_AUTOGEN_MIN && lot < LOT_AUTOGEN_MAX) { return true; }
|
||||
|
|
|
@ -60,6 +60,7 @@ struct LuaObjectTable {
|
|||
|
||||
bool smlua_valid_lot(u16 lot);
|
||||
bool smlua_valid_lvt(u16 lvt);
|
||||
struct LuaObjectField* smlua_get_object_field_from_ot(struct LuaObjectTable* ot, const char* key);
|
||||
struct LuaObjectField* smlua_get_object_field(u16 lot, const char* key);
|
||||
struct LuaObjectField* smlua_get_custom_field(lua_State* L, u32 lot, int keyIndex);
|
||||
void smlua_cobject_init_globals(void);
|
||||
|
|
|
@ -1957,12 +1957,6 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
|
|||
|
||||
struct LuaObjectField* smlua_get_object_field_autogen(u16 lot, const char* key) {
|
||||
struct LuaObjectTable* ot = &sLuaObjectAutogenTable[lot - LOT_AUTOGEN_MIN - 1];
|
||||
// TODO: change this to binary search or hash table or something
|
||||
for (int i = 0; i < ot->fieldCount; i++) {
|
||||
if (!strcmp(ot->fields[i].key, key)) {
|
||||
return &ot->fields[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return smlua_get_object_field_from_ot(ot, key);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
#include "game/print.h"
|
||||
#include "gfx_dimensions.h"
|
||||
|
||||
extern u64 SDL_GetPerformanceCounter(void);
|
||||
extern u64 SDL_GetPerformanceFrequency(void);
|
||||
|
||||
#define MAX_PROFILED_MODS 16
|
||||
#define REFRESH_RATE 15
|
||||
|
||||
|
|
Loading…
Reference in New Issue