powturbo / Turbo-Base64

Turbo Base64 - Fastest Base64 SIMD:SSE/AVX2/AVX512/Neon/Altivec - Faster than memcpy!
GNU General Public License v3.0
264 stars 40 forks source link

Maybe a URL Safe variant version? #6

Closed terrywh closed 2 years ago

terrywh commented 4 years ago

Maybe a URL Safe variant version? Mapping "+" to "-" And "/" to "_" ?

lostangelwangyang commented 4 years ago

修改tb64avx2dec():

const __m256i delta_asso   = url_safe ?
    _mm256_setr_epi8(1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 13, 0, 0, 0, 12,
                     1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 13, 0, 0, 0, 12) : /* no support '/' */
    _mm256_setr_epi8(1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 14, 0, 12, 0, 0,
                     1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 14, 0, 12, 0, 0);  /* no support '_' */

const __m256i delta_values = url_safe ?
    _mm256_setr_epi8(0, 0, 0, 17, 4, -65, -65, -71, -71, 0, 0, -65, -32, -71, 0, 0,
                     0, 0, 0, 17, 4, -65, -65, -71, -71, 0, 0, -65, -32, -71, 0, 0) :
    _mm256_setr_epi8(0, 0, 0, 16, 4, -65, -65, -71, -71, 0, 19, -65, -65, -71, -71, 0,
                     0, 0, 0, 16, 4, -65, -65, -71, -71, 0, 19, -65, -65, -71, -71, 0);