summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-01-26 20:54:14 -0600
committerDamien George <damien@micropython.org>2025-01-29 12:39:05 +1100
commitbfb1bee6feba9f06452a0e4b572ec4d15df325cf (patch)
tree22eb4169a74af88f8cadadde64260ade352fe028 /py
parentabb13b1e1e37c42876f69c83b96c9ead3285a9a7 (diff)
downloadmicropython-bfb1bee6feba9f06452a0e4b572ec4d15df325cf.tar.gz
micropython-bfb1bee6feba9f06452a0e4b572ec4d15df325cf.zip
py/parsenumbase: Favor clarity of code over manual optimisation.
Follow up to 13b13d1fdd05549d504eeded0b5aa8871d5e5dcf, 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>
Diffstat (limited to 'py')
-rw-r--r--py/parsenumbase.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/py/parsenumbase.c b/py/parsenumbase.c
index cc3275c456..fbf07a1195 100644
--- a/py/parsenumbase.c
+++ b/py/parsenumbase.c
@@ -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;