Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Optimize the base64.decode function. #185
Patch looks good to me. r+
It's a bit surprising that a property lookup is so much slower than a bunch of hardcoded if blocks. Intuitively, I'd expect table lookup to always win out over explicit branching (when not taking cache effects into account).
In any case, I wonder if doing a lookup based on the character's charCode, rather than it's string representation, would be any faster. Array element lookup is supposed to be faster than object property lookup, so I guess it depends on what the JIT can optimize. I expect it won't be faster than the inline code you just wrote, but it might be worth looking into at some point.