Skip to content

Commit b35b64a

Browse files
committed
Move static tables to namespace scope
1 parent f59cbcf commit b35b64a

File tree

1 file changed

+43
-45
lines changed

1 file changed

+43
-45
lines changed

zmij.cc

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,49 @@ constexpr auto floor_log2_pow10(int e) noexcept -> int {
341341
return e * 1741647 >> 19;
342342
}
343343

344+
constexpr uint64_t pow10s[] = {
345+
0x8000000000000000, 0xa000000000000000, 0xc800000000000000,
346+
0xfa00000000000000, 0x9c40000000000000, 0xc350000000000000,
347+
0xf424000000000000, 0x9896800000000000, 0xbebc200000000000,
348+
0xee6b280000000000, 0x9502f90000000000, 0xba43b74000000000,
349+
0xe8d4a51000000000, 0x9184e72a00000000, 0xb5e620f480000000,
350+
0xe35fa931a0000000, 0x8e1bc9bf04000000, 0xb1a2bc2ec5000000,
351+
0xde0b6b3a76400000, 0x8ac7230489e80000, 0xad78ebc5ac620000,
352+
0xd8d726b7177a8000, 0x878678326eac9000, 0xa968163f0a57b400,
353+
0xd3c21bcecceda100, 0x84595161401484a0, 0xa56fa5b99019a5c8,
354+
0xcecb8f27f4200f3a,
355+
};
356+
constexpr uint128 high_parts[] = {
357+
{0xaf8e5410288e1b6f, 0x07ecf0ae5ee44dda},
358+
{0xb1442798f49ffb4a, 0x99cd11cfdf41779d},
359+
{0xb2fe3f0b8599ef07, 0x861fa7e6dcb4aa15},
360+
{0xb4bca50b065abe63, 0x0fed077a756b53aa},
361+
{0xb67f6455292cbf08, 0x1a3bc84c17b1d543},
362+
{0xb84687c269ef3bfb, 0x3d5d514f40eea742},
363+
{0xba121a4650e4ddeb, 0x92f34d62616ce413},
364+
{0xbbe226efb628afea, 0x890489f70a55368c},
365+
{0xbdb6b8e905cb600f, 0x5400e987bbc1c921},
366+
{0xbf8fdb78849a5f96, 0xde98520472bdd034},
367+
{0xc16d9a0095928a27, 0x75b7053c0f178294},
368+
{0xc350000000000000, 0x0000000000000000},
369+
{0xc5371912364ce305, 0x6c28000000000000},
370+
{0xc722f0ef9d80aad6, 0x424d3ad2b7b97ef6},
371+
{0xc913936dd571c84c, 0x03bc3a19cd1e38ea},
372+
{0xcb090c8001ab551c, 0x5cadf5bfd3072cc6},
373+
{0xcd036837130890a1, 0x36dba887c37a8c10},
374+
{0xcf02b2c21207ef2e, 0x94f967e45e03f4bc},
375+
{0xd106f86e69d785c7, 0xe13336d701beba52},
376+
{0xd31045a8341ca07c, 0x1ede48111209a051},
377+
{0xd51ea6fa85785631, 0x552a74227f3ea566},
378+
{0xd732290fbacaf133, 0xa97c177947ad4096},
379+
{0xd94ad8b1c7380874, 0x18375281ae7822bc},
380+
};
381+
constexpr uint32_t fixups[] = {0x05271b1f, 0x00000c20, 0x00003200, 0x12100020,
382+
0x00000000, 0x06000000, 0xc16409c0, 0xaf26700f,
383+
0xeb987b07, 0x0000000d, 0x00000000, 0x66fbfffe,
384+
0xb74100ec, 0xa0669fe8, 0xedb21280, 0x00000686,
385+
0x0a021200, 0x29b89c20, 0x08bc0eda, 0x00000000};
386+
344387
// 128-bit significands of powers of 10 rounded down.
345388
struct pow10_significands_table {
346389
static constexpr bool compress = ZMIJ_OPTIMIZE_SIZE != 0;
@@ -350,51 +393,6 @@ struct pow10_significands_table {
350393

351394
// Computes the 128-bit significand of 10**i using method by Dougall Johnson.
352395
static constexpr auto compute(unsigned i) noexcept -> uint128 {
353-
constexpr uint64_t pow10s[28] = {
354-
0x8000000000000000, 0xa000000000000000, 0xc800000000000000,
355-
0xfa00000000000000, 0x9c40000000000000, 0xc350000000000000,
356-
0xf424000000000000, 0x9896800000000000, 0xbebc200000000000,
357-
0xee6b280000000000, 0x9502f90000000000, 0xba43b74000000000,
358-
0xe8d4a51000000000, 0x9184e72a00000000, 0xb5e620f480000000,
359-
0xe35fa931a0000000, 0x8e1bc9bf04000000, 0xb1a2bc2ec5000000,
360-
0xde0b6b3a76400000, 0x8ac7230489e80000, 0xad78ebc5ac620000,
361-
0xd8d726b7177a8000, 0x878678326eac9000, 0xa968163f0a57b400,
362-
0xd3c21bcecceda100, 0x84595161401484a0, 0xa56fa5b99019a5c8,
363-
0xcecb8f27f4200f3a,
364-
};
365-
366-
constexpr uint128 high_parts[23] = {
367-
{0xaf8e5410288e1b6f, 0x07ecf0ae5ee44dda},
368-
{0xb1442798f49ffb4a, 0x99cd11cfdf41779d},
369-
{0xb2fe3f0b8599ef07, 0x861fa7e6dcb4aa15},
370-
{0xb4bca50b065abe63, 0x0fed077a756b53aa},
371-
{0xb67f6455292cbf08, 0x1a3bc84c17b1d543},
372-
{0xb84687c269ef3bfb, 0x3d5d514f40eea742},
373-
{0xba121a4650e4ddeb, 0x92f34d62616ce413},
374-
{0xbbe226efb628afea, 0x890489f70a55368c},
375-
{0xbdb6b8e905cb600f, 0x5400e987bbc1c921},
376-
{0xbf8fdb78849a5f96, 0xde98520472bdd034},
377-
{0xc16d9a0095928a27, 0x75b7053c0f178294},
378-
{0xc350000000000000, 0x0000000000000000},
379-
{0xc5371912364ce305, 0x6c28000000000000},
380-
{0xc722f0ef9d80aad6, 0x424d3ad2b7b97ef6},
381-
{0xc913936dd571c84c, 0x03bc3a19cd1e38ea},
382-
{0xcb090c8001ab551c, 0x5cadf5bfd3072cc6},
383-
{0xcd036837130890a1, 0x36dba887c37a8c10},
384-
{0xcf02b2c21207ef2e, 0x94f967e45e03f4bc},
385-
{0xd106f86e69d785c7, 0xe13336d701beba52},
386-
{0xd31045a8341ca07c, 0x1ede48111209a051},
387-
{0xd51ea6fa85785631, 0x552a74227f3ea566},
388-
{0xd732290fbacaf133, 0xa97c177947ad4096},
389-
{0xd94ad8b1c7380874, 0x18375281ae7822bc},
390-
};
391-
392-
constexpr uint32_t fixups[20] = {
393-
0x05271b1f, 0x00000c20, 0x00003200, 0x12100020, 0x00000000,
394-
0x06000000, 0xc16409c0, 0xaf26700f, 0xeb987b07, 0x0000000d,
395-
0x00000000, 0x66fbfffe, 0xb74100ec, 0xa0669fe8, 0xedb21280,
396-
0x00000686, 0x0a021200, 0x29b89c20, 0x08bc0eda, 0x00000000};
397-
398396
uint64_t m = pow10s[(i + 11) % 28];
399397
uint128 h = high_parts[(i + 11) / 28];
400398

0 commit comments

Comments
 (0)