If we test for {0..9} first, we have tested for 10/16th of all possible characters first and avoid testing the remaining 6/16th of all possible characters, which can be either 6/16th lowercase or 6/16th uppercase.
Unified · Split
| @@ -28,12 +28,12 @@ · 27 unmodified lines | ||
| 28 | 28 | |
| 29 | 29 | static int convert(uint8_t x) |
| 30 | 30 | { |
| 31 | − if (x >= 'a') | |
| 32 | − x -= 87; | |
| 33 | − else if (x >= 'A') | |
| 34 | − x -= 55; | |
| 35 | − else | |
| 31 | + if (x <= '9') | |
| 36 | 32 | x -= '0'; |
| 33 | + else if (x >= 'a') | |
| 34 | + x -= ('a' - 10); | |
| 35 | + else | |
| 36 | + x -= ('A' - 10); | |
| 37 | 37 | return x; |
| 38 | 38 | } |
| 39 | 39 | |