mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 21:45:12 +00:00
Use binary search for all Lua cobject fields
This commit is contained in:
parent
5cfef9abb3
commit
0d29a29c1b
5 changed files with 13 additions and 24 deletions
|
@ -37,13 +37,7 @@ $[INCLUDES]
|
||||||
$[BODY]
|
$[BODY]
|
||||||
struct LuaObjectField* smlua_get_object_field_autogen(u16 lot, const char* key) {
|
struct LuaObjectField* smlua_get_object_field_autogen(u16 lot, const char* key) {
|
||||||
struct LuaObjectTable* ot = &sLuaObjectAutogenTable[lot - LOT_AUTOGEN_MIN - 1];
|
struct LuaObjectTable* ot = &sLuaObjectAutogenTable[lot - LOT_AUTOGEN_MIN - 1];
|
||||||
// TODO: change this to binary search or hash table or something
|
return smlua_get_object_field_from_ot(ot, key);
|
||||||
for (int i = 0; i < ot->fieldCount; i++) {
|
|
||||||
if (!strcmp(ot->fields[i].key, key)) {
|
|
||||||
return &ot->fields[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -33,13 +33,7 @@ struct LuaObjectTable sLuaObjectTable[LOT_MAX] = {
|
||||||
{ LOT_VEC3F, sVec3fFields, LUA_VEC3F_FIELD_COUNT },
|
{ LOT_VEC3F, sVec3fFields, LUA_VEC3F_FIELD_COUNT },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LuaObjectField* smlua_get_object_field(u16 lot, const char* key) {
|
struct LuaObjectField* smlua_get_object_field_from_ot(struct LuaObjectTable* ot, const char* key) {
|
||||||
if (lot > LOT_AUTOGEN_MIN) {
|
|
||||||
return smlua_get_object_field_autogen(lot, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct LuaObjectTable* ot = &sLuaObjectTable[lot];
|
|
||||||
|
|
||||||
// binary search
|
// binary search
|
||||||
s32 min = 0;
|
s32 min = 0;
|
||||||
s32 max = ot->fieldCount - 1;
|
s32 max = ot->fieldCount - 1;
|
||||||
|
@ -64,6 +58,15 @@ struct LuaObjectField* smlua_get_object_field(u16 lot, const char* key) {
|
||||||
return NULL;
|
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) {
|
bool smlua_valid_lot(u16 lot) {
|
||||||
if (lot > LOT_NONE && lot < LOT_MAX) { return true; }
|
if (lot > LOT_NONE && lot < LOT_MAX) { return true; }
|
||||||
if (lot > LOT_AUTOGEN_MIN && lot < LOT_AUTOGEN_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_lot(u16 lot);
|
||||||
bool smlua_valid_lvt(u16 lvt);
|
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_object_field(u16 lot, const char* key);
|
||||||
struct LuaObjectField* smlua_get_custom_field(lua_State* L, u32 lot, int keyIndex);
|
struct LuaObjectField* smlua_get_custom_field(lua_State* L, u32 lot, int keyIndex);
|
||||||
void smlua_cobject_init_globals(void);
|
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 LuaObjectField* smlua_get_object_field_autogen(u16 lot, const char* key) {
|
||||||
struct LuaObjectTable* ot = &sLuaObjectAutogenTable[lot - LOT_AUTOGEN_MIN - 1];
|
struct LuaObjectTable* ot = &sLuaObjectAutogenTable[lot - LOT_AUTOGEN_MIN - 1];
|
||||||
// TODO: change this to binary search or hash table or something
|
return smlua_get_object_field_from_ot(ot, key);
|
||||||
for (int i = 0; i < ot->fieldCount; i++) {
|
|
||||||
if (!strcmp(ot->fields[i].key, key)) {
|
|
||||||
return &ot->fields[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
#include "game/print.h"
|
#include "game/print.h"
|
||||||
#include "gfx_dimensions.h"
|
#include "gfx_dimensions.h"
|
||||||
|
|
||||||
extern u64 SDL_GetPerformanceCounter(void);
|
|
||||||
extern u64 SDL_GetPerformanceFrequency(void);
|
|
||||||
|
|
||||||
#define MAX_PROFILED_MODS 16
|
#define MAX_PROFILED_MODS 16
|
||||||
#define REFRESH_RATE 15
|
#define REFRESH_RATE 15
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue