Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve enc.Base64 parse performance by x10.
I replaced the linear map.indexOf() lookup with a reverse lookup table (an array of charCodes turned out to be significantly faster than an object with actual char keys, even though both are O(1)), for a speedup of about x2 on large-ish strings. The change is compatible with reuses of enc.Base64 that provide a different map. I also extracted the inner loop into its own function, since for some reason Chrome was consistently de-optimizing the parse function when the loop was embedded in it. This way, both functions get optimized for an additional speedup of about x5 in my tests.
- Loading branch information