From bd86ce5f8213398a196019ad517df42e27fc173d Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 17 Jan 2023 17:32:53 +1100 Subject: [PATCH] lib/re1.5: Reduce code size when checking for named class char. Signed-off-by: Damien George --- lib/re1.5/compilecode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/re1.5/compilecode.c b/lib/re1.5/compilecode.c index add4f6ac20..d4fc2a2895 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);