Skip to content

Commit 3cdc3c5

Browse files
committed
Minor cleanups, align lookup tables to 64 bytes (NFC)
No performance changes. Base85 tables were probably already aligned.
1 parent 879dd86 commit 3cdc3c5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Modules/binascii.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ base64_decode_fast(const unsigned char *in, Py_ssize_t in_len,
188188
}
189189

190190

191-
static const unsigned char table_a2b_base85[] = {
191+
static const unsigned char table_a2b_base85[] Py_ALIGNED(64) = {
192192
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
193193
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
194194
-1,62,-1,63, 64,65,66,-1, 67,68,69,70, -1,71,-1,-1,
@@ -208,7 +208,7 @@ static const unsigned char table_a2b_base85[] = {
208208
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
209209
};
210210

211-
static const unsigned char table_a2b_base85_a85[] = {
211+
static const unsigned char table_a2b_base85_a85[] Py_ALIGNED(64) = {
212212
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
213213
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
214214
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
@@ -228,7 +228,7 @@ static const unsigned char table_a2b_base85_a85[] = {
228228
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
229229
};
230230

231-
static const unsigned char table_a2b_base85_z85[] = {
231+
static const unsigned char table_a2b_base85_z85[] Py_ALIGNED(64) = {
232232
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
233233
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
234234
-1,68,-1,84, 83,82,72,-1, 75,76,70,65, -1,63,62,69,
@@ -248,15 +248,15 @@ static const unsigned char table_a2b_base85_z85[] = {
248248
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
249249
};
250250

251-
static const unsigned char table_b2a_base85[] =
251+
static const unsigned char table_b2a_base85[] Py_ALIGNED(64) =
252252
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
253253
"abcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~";
254254

255-
static const unsigned char table_b2a_base85_a85[] =
255+
static const unsigned char table_b2a_base85_a85[] Py_ALIGNED(64) =
256256
"!\"#$%&\'()*+,-./0123456789:;<=>?@" \
257257
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu";
258258

259-
static const unsigned char table_b2a_base85_z85[] =
259+
static const unsigned char table_b2a_base85_z85[] Py_ALIGNED(64) =
260260
"0123456789abcdefghijklmnopqrstuvwxyz" \
261261
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/\x2a?&<>()[]{}@%$#"; /* clinic doesn't like '/' followed by '*' */
262262

@@ -857,7 +857,8 @@ binascii_a2b_ascii85_impl(PyObject *module, Py_buffer *data, int fold_spaces,
857857
ascii_len -= 2;
858858
if (ascii_len >= 2
859859
&& ascii_data[0] == BASE85_A85_PREFIX
860-
&& ascii_data[1] == BASE85_A85_AFFIX) {
860+
&& ascii_data[1] == BASE85_A85_AFFIX)
861+
{
861862
ascii_data += 2;
862863
ascii_len -= 2;
863864
}
@@ -995,9 +996,7 @@ binascii_b2a_ascii85_impl(PyObject *module, Py_buffer *data, int fold_spaces,
995996
width = 2;
996997
}
997998

998-
/* Allocate output buffer.
999-
XXX: Do a pre-pass above some threshold estimate (cf. 'yz')?
1000-
*/
999+
/* Allocate output buffer. */
10011000
Py_ssize_t out_len = 5 * ((bin_len + 3) / 4);
10021001
if (wrap) {
10031002
out_len += 4;

0 commit comments

Comments
 (0)