From b8587edf5f433d03c3a052216c8437ac9d103795 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 18 Aug 2017 01:00:16 +0000 Subject: [PATCH] Simplified a bit of JavaScript code. --- javascript/qrcodegen.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 4f28398..9ac90bd 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -1004,8 +1004,7 @@ var qrcodegen = new function() { // Returns a copy of all bytes, padding up to the nearest byte. this.getBytes = function() { var result = []; - var numBytes = Math.ceil(bitData.length / 8); - for (var i = 0; i < numBytes; i++) + while (result.length * 8 < bitData.length) result.push(0); bitData.forEach(function(bit, i) { result[i >>> 3] |= bit << (7 - (i & 7));