mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
Avoid unnecessarily initializing disassembler
This commit is contained in:
parent
5161ef8ff3
commit
f77c9720a6
2 changed files with 6 additions and 1 deletions
|
@ -14,6 +14,7 @@ namespace Common {
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool isInitialized() { return initialized; }
|
||||||
void init(cs_arch arch, cs_mode mode) { initialized = (cs_open(arch, mode, &handle) == CS_ERR_OK); }
|
void init(cs_arch arch, cs_mode mode) { initialized = (cs_open(arch, mode, &handle) == CS_ERR_OK); }
|
||||||
|
|
||||||
CapstoneDisassembler() {}
|
CapstoneDisassembler() {}
|
||||||
|
|
|
@ -209,7 +209,11 @@ static int getButtonThunk(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int disassembleARMThunk(lua_State* L) {
|
static int disassembleARMThunk(lua_State* L) {
|
||||||
static Common::CapstoneDisassembler disassembler(CS_ARCH_ARM, CS_MODE_ARM);
|
static Common::CapstoneDisassembler disassembler;
|
||||||
|
// We want the disassembler to only be fully initialized when this function is first used
|
||||||
|
if (!disassembler.isInitialized()) {
|
||||||
|
disassembler.init(CS_ARCH_ARM, CS_MODE_ARM);
|
||||||
|
}
|
||||||
|
|
||||||
const u32 pc = u32(lua_tonumber(L, 1));
|
const u32 pc = u32(lua_tonumber(L, 1));
|
||||||
const u32 instruction = u32(lua_tonumber(L, 2));
|
const u32 instruction = u32(lua_tonumber(L, 2));
|
||||||
|
|
Loading…
Add table
Reference in a new issue