Avoid unnecessarily initializing disassembler
This commit is contained in:
@@ -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));
|
||||||
|
|||||||
Reference in New Issue
Block a user