From ccd571624e2e380171e4d7d1fc8d27ed72863f22 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sun, 26 Aug 2018 02:17:47 +0000 Subject: [PATCH] Tweaked QrCode constructor to dispose of the isFunction array in all languages except C, but somewhat differently in each language. --- cpp/QrCode.cpp | 2 ++ java/io/nayuki/qrcodegen/QrCode.java | 1 + javascript/qrcodegen.js | 1 + python/qrcodegen.py | 1 + rust/src/lib.rs | 2 ++ typescript/qrcodegen.ts | 1 + 6 files changed, 8 insertions(+) diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index 99bdd11..3c6046a 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -129,6 +129,8 @@ QrCode::QrCode(int ver, Ecc ecl, const vector &dataCodewords, int mask) const vector allCodewords = addEccAndInterleave(dataCodewords); drawCodewords(allCodewords); this->mask = handleConstructorMasking(mask); + isFunction.clear(); + isFunction.shrink_to_fit(); } diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index 225f2e7..7cf0900 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -230,6 +230,7 @@ public final class QrCode { byte[] allCodewords = addEccAndInterleave(dataCodewords); drawCodewords(allCodewords); this.mask = handleConstructorMasking(mask); + isFunction = null; } diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 2f9579f..dfb768a 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -113,6 +113,7 @@ var qrcodegen = new function() { throw "Assertion error"; drawFormatBits(mask); // Overwrite old format bits applyMask(mask); // Apply the final choice of mask + isFunction = null; /*---- Read-only instance properties ----*/ diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 8e297af..1c0cda5 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -188,6 +188,7 @@ class QrCode(object): self._draw_format_bits(mask) # Overwrite old format bits self._apply_mask(mask) # Apply the final choice of mask self._mask = mask + del self._isfunction # ---- Accessor methods ---- diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 82abe1d..5654b0a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -186,6 +186,8 @@ impl QrCode { let allcodewords: Vec = result.add_ecc_and_interleave(datacodewords); result.draw_codewords(&allcodewords); result.handle_constructor_masking(mask); + result.isfunction.clear(); + result.isfunction.shrink_to_fit(); result } diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index c1e4862..3ae9bc7 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -194,6 +194,7 @@ namespace qrcodegen { this.mask = mask; this.drawFormatBits(mask); // Overwrite old format bits this.applyMask(mask); // Apply the final choice of mask + this.isFunction = []; }