From ea33faf535cf55fcb5ae11fa566ecabfb7053772 Mon Sep 17 00:00:00 2001 From: Nav Date: Thu, 14 Sep 2023 21:16:03 +0100 Subject: [PATCH] Tidying --- .../Microchip/AVR/AVR8/OpcodeDecoder/Decoder.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Targets/Microchip/AVR/AVR8/OpcodeDecoder/Decoder.cpp b/src/Targets/Microchip/AVR/AVR8/OpcodeDecoder/Decoder.cpp index c861e457..4b119200 100644 --- a/src/Targets/Microchip/AVR/AVR8/OpcodeDecoder/Decoder.cpp +++ b/src/Targets/Microchip/AVR/AVR8/OpcodeDecoder/Decoder.cpp @@ -21,9 +21,8 @@ namespace Targets::Microchip::Avr::Avr8Bit::OpcodeDecoder auto dataIt = data.begin(); const auto dataEndIt = data.end(); - while(dataIt != dataEndIt) { + while (std::distance(dataIt, dataEndIt) >= 2) { auto opcodeMatched = false; - const auto wordAvailable = std::distance(dataIt, dataEndIt) >= 2; for (const auto& decoder : decoders) { auto instruction = decoder(dataIt, dataEndIt); @@ -43,18 +42,12 @@ namespace Targets::Microchip::Avr::Avr8Bit::OpcodeDecoder if (throwOnFailure) { throw Exceptions::DecodeFailure( instructionByteAddress, - wordAvailable - ? static_cast(*(dataIt + 1) << 8) | *dataIt - : *dataIt + static_cast(*(dataIt + 1) << 8) | *dataIt ); } output.insert(std::pair(instructionByteAddress, std::nullopt)); - if (!wordAvailable) { - break; - } - dataIt += 2; instructionByteAddress += 2; }