Skip to content

Commit bfb1bee

Browse files
jeplerdpgeorge
authored andcommitted
py/parsenumbase: Favor clarity of code over manual optimisation.
Follow up to 13b13d1, 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 <[email protected]>
1 parent abb13b1 commit bfb1bee

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

py/parsenumbase.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ size_t mp_parse_num_base(const char *str, size_t len, int *base) {
4141
if (c == '0') {
4242
c = *(p++) | 32;
4343
int b = *base;
44-
if (c == 'x' && !(b & ~16)) {
44+
if (c == 'x' && (b == 0 || b == 16)) {
4545
*base = 16;
46-
} else if (c == 'o' && !(b & ~8)) {
46+
} else if (c == 'o' && (b == 0 || b == 8)) {
4747
*base = 8;
48-
} else if (c == 'b' && !(b & ~2)) {
48+
} else if (c == 'b' && (b == 0 || b == 2)) {
4949
*base = 2;
5050
} else {
5151
p -= 2;

0 commit comments

Comments
 (0)