Browse Source

init(): cache code.length

master
Feross Aboukhadijeh 9 years ago
parent
commit
1215b36b4d
  1. 5
      lib/b64.js

5
lib/b64.js

@ -10,12 +10,13 @@ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
function init () { function init () {
var i var i
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var len = code.length
for (i = 0; i < code.length; i++) { for (i = 0; i < len; i++) {
lookup[i] = code[i] lookup[i] = code[i]
} }
for (i = 0; i < code.length; ++i) { for (i = 0; i < len; ++i) {
revLookup[code.charCodeAt(i)] = i revLookup[code.charCodeAt(i)] = i
} }
revLookup['-'.charCodeAt(0)] = 62 revLookup['-'.charCodeAt(0)] = 62

Loading…
Cancel
Save