Skip to content

Commit 64e196c

Browse files
authored
Merge pull request #81 from steveluscher/this-but-faster
Improve decoding performance
2 parents 39f2673 + 261fb36 commit 64e196c

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/cjs/index.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function base (ALPHABET) {
8181
const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
8282
const b256 = new Uint8Array(size)
8383
// Process the characters.
84-
while (source[psz]) {
84+
while (psz < source.length) {
8585
// Decode character
8686
let carry = BASE_MAP[source.charCodeAt(psz)]
8787
// Invalid character

src/esm/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function base (ALPHABET) {
7979
const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
8080
const b256 = new Uint8Array(size)
8181
// Process the characters.
82-
while (source[psz]) {
82+
while (psz < source.length) {
8383
// Decode character
8484
let carry = BASE_MAP[source.charCodeAt(psz)]
8585
// Invalid character

ts_src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function base (ALPHABET: string): base.BaseConverter {
100100
const b256 = new Uint8Array(size)
101101

102102
// Process the characters.
103-
while (source[psz]) {
103+
while (psz < source.length) {
104104
// Decode character
105105
let carry = BASE_MAP[source.charCodeAt(psz)]
106106

0 commit comments

Comments
 (0)