@@ -1203,19 +1203,6 @@ binascii_unhexlify_impl(PyObject *module, Py_buffer *hexstr)
12031203 return binascii_a2b_hex_impl (module , hexstr );
12041204}
12051205
1206- static const int table_hex [128 ] = {
1207- -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 ,
1208- -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 ,
1209- -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 ,
1210- 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 ,
1211- -1 ,10 ,11 ,12 , 13 ,14 ,15 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 ,
1212- -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 ,
1213- -1 ,10 ,11 ,12 , 13 ,14 ,15 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 ,
1214- -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1 , -1 ,-1 ,-1 ,-1
1215- };
1216-
1217- #define hexval (c ) table_hex[(unsigned int)(c)]
1218-
12191206#define MAXLINESIZE 76
12201207
12211208
@@ -1233,7 +1220,7 @@ binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header)
12331220/*[clinic end generated code: output=e99f7846cfb9bc53 input=bf6766fea76cce8f]*/
12341221{
12351222 Py_ssize_t in , out ;
1236- char ch ;
1223+ unsigned int top , bot ;
12371224 const unsigned char * ascii_data ;
12381225 unsigned char * odata ;
12391226 Py_ssize_t datalen = 0 ;
@@ -1271,18 +1258,11 @@ binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header)
12711258 in ++ ;
12721259 }
12731260 else if ((in + 1 < datalen ) &&
1274- ((ascii_data [in ] >= 'A' && ascii_data [in ] <= 'F' ) ||
1275- (ascii_data [in ] >= 'a' && ascii_data [in ] <= 'f' ) ||
1276- (ascii_data [in ] >= '0' && ascii_data [in ] <= '9' )) &&
1277- ((ascii_data [in + 1 ] >= 'A' && ascii_data [in + 1 ] <= 'F' ) ||
1278- (ascii_data [in + 1 ] >= 'a' && ascii_data [in + 1 ] <= 'f' ) ||
1279- (ascii_data [in + 1 ] >= '0' && ascii_data [in + 1 ] <= '9' ))) {
1280- /* hexval */
1281- ch = hexval (ascii_data [in ]) << 4 ;
1282- in ++ ;
1283- ch |= hexval (ascii_data [in ]);
1284- in ++ ;
1285- odata [out ++ ] = ch ;
1261+ ((top = _PyLong_DigitValue [ascii_data [in ]]) < 16 ) &&
1262+ ((bot = _PyLong_DigitValue [ascii_data [in + 1 ]]) < 16 ))
1263+ {
1264+ odata [out ++ ] = (top << 4 ) + bot ;
1265+ in += 2 ;
12861266 }
12871267 else {
12881268 odata [out ++ ] = '=' ;
0 commit comments