标签:class for bubuko device output res man ice com
See example below firstly.
uint8_t parity = 0; uint8_t index = 0; //flag gMUXTask.responseData[index++] = MUX_DATA_BIT_LOW; //dirty gMUXTask.responseData[index++] = gDeviceStatus.responseStatus.dirty; parity += gDeviceStatus.responseStatus.dirty; //smoke alarm gMUXTask.responseData[index++] = gDeviceStatus.responseStatus.smokeAlarm; parity += gDeviceStatus.responseStatus.smokeAlarm; //high temperature gMUXTask.responseData[index++] = gDeviceStatus.responseStatus.highTemperature; parity += gDeviceStatus.responseStatus.highTemperature; //low temperature gMUXTask.responseData[index++] = gDeviceStatus.responseStatus.lowTemperature; parity += gDeviceStatus.responseStatus.lowTemperature; //miss Head gMUXTask.responseData[index++] = gDeviceStatus.responseStatus.missHead; parity += gDeviceStatus.responseStatus.missHead; //parity gMUXTask.responseData[index++] = CalcParity(isOddAlgorithm(false), parity); //outputState gMUXTask.responseData[index++] = MUX_DATA_BIT_LOW;
The ASM code generated is below, it is around 120bytes.
Another example here,
uint8_t* p = gMUXTask.responseData; *p++ = MUX_DATA_BIT_LOW; //dirty *p++ = gDeviceStatus.responseStatus.dirty; parity += gDeviceStatus.responseStatus.dirty; //smoke alarm *p++ = gDeviceStatus.responseStatus.smokeAlarm; parity += gDeviceStatus.responseStatus.smokeAlarm; //high temperature *p++ = gDeviceStatus.responseStatus.highTemperature; parity += gDeviceStatus.responseStatus.highTemperature; //low temperature *p++ = gDeviceStatus.responseStatus.lowTemperature; parity += gDeviceStatus.responseStatus.lowTemperature; //miss Head *p++ = gDeviceStatus.responseStatus.missHead; parity += gDeviceStatus.responseStatus.missHead; //parity *p++ = CalcParity(isOddAlgorithm(false), parity); //outputState *p++ = MUX_DATA_BIT_LOW;
The ASM code generated, it is about 106 bytes.
Using pointer to access an array which has a better performance.
Using pointer to access array instead of index
标签:class for bubuko device output res man ice com
原文地址:https://www.cnblogs.com/zjbfvfv/p/10329446.html