src: make base64 decoding 50% faster
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 15 Jul 2015 20:09:52 +0000 (22:09 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Sat, 25 Jul 2015 17:07:23 +0000 (19:07 +0200)
commit8fd3ce100eb30324f01da8f4e8d501a0369c6a44
tree95c578c5176d70432e2f22eea73fe0c2975259fd
parentb148c0dff3c41d59886352eb5dfd4d217db0a02d
src: make base64 decoding 50% faster

Make the inner loop execute fewer compare-and-branch executions per
processed byte, resulting in a 50% or more speedup.

This coincidentally fixes an out-of-bounds read:

    while (unbase64(*src) < 0 && src < srcEnd)

Should have read:

    while (src < srcEnd && unbase64(*src) < 0)

But this commit removes the offending code altogether.

Fixes: https://github.com/nodejs/io.js/issues/2166
PR-URL: https://github.com/nodejs/io.js/pull/2193
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
benchmark/buffers/buffer-base64-decode.js [new file with mode: 0644]
src/string_bytes.cc