From c35ea64166bd59bef810f06aeb13a2e92a136620 Mon Sep 17 00:00:00 2001 From: Curve Date: Mon, 20 May 2024 18:55:01 +0200 Subject: [PATCH] refactor(instruction/prev): return first matching * Idea is that the diasassembler is more likely to find (bad) small instructions instead of large ones --- src/instruction.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/instruction.cpp b/src/instruction.cpp index 7df60c3..030bd1b 100644 --- a/src/instruction.cpp +++ b/src/instruction.cpp @@ -63,10 +63,14 @@ namespace lime return disasm::immediates(m_impl->address); } + std::optional instruction::next() const + { + return *this + size(); + } + std::optional instruction::prev() const { const auto start = m_impl->address - max_instruction_size; - std::optional last; for (auto current = start; current < m_impl->address; current++) { @@ -84,16 +88,10 @@ namespace lime continue; } - last.emplace(std::move(instruction.value())); - break; + return instruction; } - return last; - } - - std::optional instruction::next() const - { - return *this + size(); + return std::nullopt; } std::optional instruction::next(std::size_t mnemonic) const