From 0a96eec52e7d3b5f159e973dbc7f0d78258de491 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 31 Aug 2018 17:00:52 +0000 Subject: [PATCH] Simplified small pieces of TypeScript and JavaScript code. --- javascript/qrcodegen.js | 5 +---- typescript/qrcodegen.ts | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index fc09624..bb4096e 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -329,10 +329,7 @@ var qrcodegen = new function() { var ecc = rs.getRemainder(dat); if (i < numShortBlocks) dat.push(0); - ecc.forEach(function(b) { - dat.push(b); - }); - blocks.push(dat); + blocks.push(dat.concat(ecc)); } // Interleave (not concatenate) the bytes from every block into a single sequence diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index 1bedfff..43012cb 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -399,9 +399,7 @@ namespace qrcodegen { let ecc: Array = rs.getRemainder(dat); if (i < numShortBlocks) dat.push(0); - ecc.forEach( - (b: byte) => dat.push(b)); - blocks.push(dat); + blocks.push(dat.concat(ecc)); } // Interleave (not concatenate) the bytes from every block into a single sequence @@ -770,8 +768,7 @@ namespace qrcodegen { // the given version. The result is infinity if a segment has too many characters to fit its length field. public static getTotalBits(segs: Array, version: int): number { let result: number = 0; - for (let i = 0; i < segs.length; i++) { - let seg: QrSegment = segs[i]; + for (let seg of segs) { let ccbits: int = seg.mode.numCharCountBits(version); if (seg.numChars >= (1 << ccbits)) return Infinity; // The segment's length doesn't fit the field's bit width