Skip to content

Commit

Permalink
Remove duplicate code from IRToshibaAC::calcChecksum() (#1207)
Browse files Browse the repository at this point in the history
  • Loading branch information
crankyoldgit authored Jun 28, 2020
1 parent 0fb37a3 commit edcc932
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/ir_Toshiba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,7 @@ void IRToshibaAC::setRaw(const uint8_t newState[]) {
/// @return The calculated checksum value.
uint8_t IRToshibaAC::calcChecksum(const uint8_t state[],
const uint16_t length) {
uint8_t checksum = 0;
// Only calculate it for valid lengths.
if (length > 1) {
// Checksum is simple XOR of all bytes except the last one.
for (uint8_t i = 0; i < length - 1; i++) checksum ^= state[i];
}
return checksum;
return length ? xorBytes(state, length - 1) : 0;
}

/// Verify the checksum is valid for a given state.
Expand Down

0 comments on commit edcc932

Please sign in to comment.