Simplify bool array converter functions.

This commit is contained in:
László Monda
2017-05-31 01:41:44 +02:00
parent a8cb94ef15
commit b969feb346

View File

@@ -5,13 +5,13 @@ void BoolBytesToBits(uint8_t *srcBytes, uint8_t *dstBits, uint8_t byteCount)
{
memset(dstBits, 0, byteCount/8 + 1);
for (uint8_t i=0; i<byteCount; i++) {
dstBits[i/8] |= (srcBytes[i] ? 1 : 0) << (i % 8);
dstBits[i/8] |= !!srcBytes[i] << (i % 8);
}
}
void BoolBitsToBytes(uint8_t *srcBits, uint8_t *dstBytes, uint8_t byteCount)
{
for (uint8_t i=0; i<byteCount; i++) {
dstBytes[i] = (srcBits[i/8] & (1 << (i % 8))) ? 1 : 0;
dstBytes[i] = !!(srcBits[i/8] & (1 << (i % 8)));
}
}