Optimize quirc_flip()

This commit is contained in:
Claudio Felber 2020-09-22 12:14:09 +02:00
parent 5beb59e3b4
commit 4bc17cf8c6
2 changed files with 13 additions and 14 deletions

View file

@ -919,13 +919,12 @@ quirc_decode_error_t quirc_decode(const struct quirc_code *code,
void quirc_flip(struct quirc_code *code) void quirc_flip(struct quirc_code *code)
{ {
struct quirc_code flipped; struct quirc_code flipped = {0};
memset(&flipped, 0, sizeof(flipped)); unsigned int offset = 0;
int offset = 0; for (int y = 0; y < code->size; y++) {
for (int y = 0, sx = 0; y < code->size; y++, sx++) { for (int x = 0; x < code->size; x++) {
for (int x = 0, sy = 0; x < code->size; x++, sy++) { if (grid_bit(code, y, x)) {
if (grid_bit(code, sx, sy)) { flipped.cell_bitmap[offset >> 3u] |= (1u << (offset & 7u));
flipped.cell_bitmap[offset >> 3] |= (1 << (offset & 7));
} }
offset++; offset++;
} }