py/parsenumbase: Favor clarity of code over manual optimisation.

Follow up to 13b13d1fdd, based on some
testing on godbolt, the manual code optimisation seems unnecessary for code
size, at least on gcc x86_64 and ARM, and it's definitely not good for
clarity.

Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
Jeff Epler 2025-01-26 20:54:14 -06:00 committed by Damien George
parent abb13b1e1e
commit bfb1bee6fe

View file

@ -41,11 +41,11 @@ size_t mp_parse_num_base(const char *str, size_t len, int *base) {
if (c == '0') {
c = *(p++) | 32;
int b = *base;
if (c == 'x' && !(b & ~16)) {
if (c == 'x' && (b == 0 || b == 16)) {
*base = 16;
} else if (c == 'o' && !(b & ~8)) {
} else if (c == 'o' && (b == 0 || b == 8)) {
*base = 8;
} else if (c == 'b' && !(b & ~2)) {
} else if (c == 'b' && (b == 0 || b == 2)) {
*base = 2;
} else {
p -= 2;