From fe138bedbd8046bb6b13106c921c468a13e7ca64 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 29 Feb 2016 08:16:43 -0800 Subject: [PATCH] inline push() in toByteArray() --- lib/b64.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/b64.js b/lib/b64.js index 30b5764..fc63521 100644 --- a/lib/b64.js +++ b/lib/b64.js @@ -49,24 +49,20 @@ function toByteArray (b64) { var L = 0 - function push (v) { - arr[L++] = v - } - for (i = 0, j = 0; i < l; i += 4, j += 3) { tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) + arr[L++] = (tmp & 0xFF0000) >> 16 + arr[L++] = (tmp & 0xFF00) >> 8 + arr[L++] = tmp & 0xFF } if (placeHolders === 2) { tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) + arr[L++] = tmp & 0xFF } else if (placeHolders === 1) { tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } return arr