1 | /*
|
---|
2 | * Copyright 2012 Tri-Edge AI <triedgeai@gmail.com>
|
---|
3 | * All rights reserved. Distributed under the terms of the MIT license.
|
---|
4 | */
|
---|
5 |
|
---|
6 | long __a64l_map[] = {
|
---|
7 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00
|
---|
8 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10
|
---|
9 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0x20
|
---|
10 | 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, // 0x30
|
---|
11 | 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, // 0x40
|
---|
12 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 0, 0, 0, 0, 0, // 0x50
|
---|
13 | 0, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, // 0x60
|
---|
14 | 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 0, 0, 0, 0, // 0x70
|
---|
15 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 0x80
|
---|
16 | };
|
---|
17 |
|
---|
18 | long
|
---|
19 | a64l(const char* s)
|
---|
20 | {
|
---|
21 | long result = 0;
|
---|
22 |
|
---|
23 | // Unrolled for maximum performance.
|
---|
24 |
|
---|
25 | if (s[0] == '\0')
|
---|
26 | return 0;
|
---|
27 |
|
---|
28 | result = __a64l_map[s[0]];
|
---|
29 |
|
---|
30 | if (s[1] == '\0')
|
---|
31 | return result;
|
---|
32 |
|
---|
33 | result += __a64l_map[s[1]] * (64);
|
---|
34 |
|
---|
35 | if (s[2] == '\0')
|
---|
36 | return result;
|
---|
37 |
|
---|
38 | result += __a64l_map[s[2]] * (64 * 64);
|
---|
39 |
|
---|
40 | if (s[3] == '\0')
|
---|
41 | return result;
|
---|
42 |
|
---|
43 | result += __a64l_map[s[3]] * (64 * 64 * 64);
|
---|
44 |
|
---|
45 | if (s[4] == '\0')
|
---|
46 | return result;
|
---|
47 |
|
---|
48 | result += __a64l_map[s[4]] * (64 * 64 * 64 * 64);
|
---|
49 |
|
---|
50 | if (s[5] == '\0')
|
---|
51 | return result;
|
---|
52 |
|
---|
53 | result += __a64l_map[s[5]] * (64 * 64 * 64 * 64 * 64);
|
---|
54 |
|
---|
55 | return result;
|
---|
56 | }
|
---|