Browse Source

inline push() in toByteArray()

master
Feross Aboukhadijeh 9 years ago
parent
commit
fe138bedbd
  1. 16
      lib/b64.js

16
lib/b64.js

@ -49,24 +49,20 @@ function toByteArray (b64) {
var L = 0 var L = 0
function push (v) {
arr[L++] = v
}
for (i = 0, j = 0; i < l; i += 4, j += 3) { 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)) 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) arr[L++] = (tmp & 0xFF0000) >> 16
push((tmp & 0xFF00) >> 8) arr[L++] = (tmp & 0xFF00) >> 8
push(tmp & 0xFF) arr[L++] = tmp & 0xFF
} }
if (placeHolders === 2) { if (placeHolders === 2) {
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
push(tmp & 0xFF) arr[L++] = tmp & 0xFF
} else if (placeHolders === 1) { } else if (placeHolders === 1) {
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
push((tmp >> 8) & 0xFF) arr[L++] = (tmp >> 8) & 0xFF
push(tmp & 0xFF) arr[L++] = tmp & 0xFF
} }
return arr return arr

Loading…
Cancel
Save