performance optimization by dron0gus

This commit is contained in:
Andrey 2021-06-21 09:27:09 -04:00
parent 607ece65c2
commit 498358247e
2 changed files with 6 additions and 2 deletions

View File

@ -323,7 +323,9 @@ static void handleCrc32Check(TsChannelBase *tsChannel, ts_response_format_e mode
const char* start = getWorkingPageAddr() + offset; const char* start = getWorkingPageAddr() + offset;
uint32_t crc = SWAP_UINT32(crc32(start, count)); uint32_t crc = crc32(start, count);
// do not pass function as macro parameter that would cause same code to be invoked 4 times!
crc = SWAP_UINT32(crc);
tsChannel->sendResponse(mode, (const uint8_t *) &crc, 4); tsChannel->sendResponse(mode, (const uint8_t *) &crc, 4);
} }

View File

@ -155,7 +155,9 @@ void canMazdaRX8(CanCycle cycle) {
float kph = getVehicleSpeed(); float kph = getVehicleSpeed();
msg.setShortValue(SWAP_UINT16(GET_RPM() * 4), 0); int rpm = GET_RPM();
// do not pass function as macro parameter that would cause same code to be invoked 4 times!
msg.setShortValue(SWAP_UINT16(rpm * 4), 0);
msg.setShortValue(0xFFFF, 2); msg.setShortValue(0xFFFF, 2);
msg.setShortValue(SWAP_UINT16((int )(100 * kph + 10000)), 4); msg.setShortValue(SWAP_UINT16((int )(100 * kph + 10000)), 4);
msg.setShortValue(0, 6); msg.setShortValue(0, 6);