diff options
author | Damien George <damien@micropython.org> | 2023-01-17 17:32:53 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-01-18 09:15:32 +1100 |
commit | bd86ce5f8213398a196019ad517df42e27fc173d (patch) | |
tree | d05c3b3a5bc92fa3d7471e317016238059a9a5b2 /lib | |
parent | 1583c1f6701a2545f0de042e886ee9afc26dfb74 (diff) |
lib/re1.5: Reduce code size when checking for named class char.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/re1.5/compilecode.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/re1.5/compilecode.c b/lib/re1.5/compilecode.c index add4f6ac2..d4fc2a289 100644 --- a/lib/re1.5/compilecode.c +++ b/lib/re1.5/compilecode.c @@ -4,6 +4,9 @@ #include "re1.5.h" +// Matches: DSWdsw +#define MATCH_NAMED_CLASS_CHAR(c) (((c) | 0x20) == 'd' || ((c) | 0x24) == 'w') + #define INSERT_CODE(at, num, pc) \ ((code ? memmove(code + at + num, code + at, pc - at) : 0), pc += num) #define REL(at, to) (to - at - 2) @@ -31,7 +34,7 @@ static const char *_compilecode(const char *re, ByteProg *prog, int sizecode) case '\\': re++; if (!*re) return NULL; // Trailing backslash - if ((*re | 0x20) == 'd' || (*re | 0x20) == 's' || (*re | 0x20) == 'w') { + if (MATCH_NAMED_CLASS_CHAR(*re)) { term = PC; EMIT(PC++, NamedClass); EMIT(PC++, *re); |