From 1f62fa4909940639faf8cb24e839a49668f1707d Mon Sep 17 00:00:00 2001 From: Clement Burin des Roziers Date: Fri, 31 Oct 2014 14:50:22 +0100 Subject: [PATCH] CRC32: improved computation time Reading one byte at a time was so slow that it caused the gdb client to timeout. --- src/crc32.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/crc32.c b/src/crc32.c index 6f1c0e3..16cc565 100644 --- a/src/crc32.c +++ b/src/crc32.c @@ -97,13 +97,19 @@ uint32_t crc32_calc(uint32_t crc, uint8_t data) uint32_t generic_crc32(target *t, uint32_t base, int len) { uint32_t crc = -1; - uint8_t byte; + static uint8_t bytes[128]; - while (len--) { - byte = target_mem_read8(t, base); + while (len) { + uint32_t i; + uint32_t read_len = len >= 128 ? 128 : len; - crc = crc32_calc(crc, byte); - base++; + target_mem_read(t, bytes, base, read_len); + + for (i=0; i