From c99bb61f417aed59933cee659230a57343e8fcbf Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 6 May 2017 11:35:44 +0000 Subject: [PATCH] Added local variables to a C function to shorten code width. --- c/qrcodegen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 25b204d..0533079 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -386,8 +386,9 @@ static void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ec // Returns the number of 8-bit codewords that can be used for storing data (not ECC), // for the given version number and error correction level. The result is in the range [9, 2956]. testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl) { - assert(0 <= (int)ecl && (int)ecl < 4 && qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX); - return getNumRawDataModules(version) / 8 - ECC_CODEWORDS_PER_BLOCK[(int)ecl][version] * NUM_ERROR_CORRECTION_BLOCKS[(int)ecl][version]; + int v = version, e = (int)ecl; + assert(0 <= e && e < 4 && qrcodegen_VERSION_MIN <= v && v <= qrcodegen_VERSION_MAX); + return getNumRawDataModules(v) / 8 - ECC_CODEWORDS_PER_BLOCK[e][v] * NUM_ERROR_CORRECTION_BLOCKS[e][v]; }