mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 00:50:24 +08:00
lib/re1.5: Reduce code size when checking for named class char.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
1583c1f670
commit
bd86ce5f82
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
#include "re1.5.h"
|
#include "re1.5.h"
|
||||||
|
|
||||||
|
// Matches: DSWdsw
|
||||||
|
#define MATCH_NAMED_CLASS_CHAR(c) (((c) | 0x20) == 'd' || ((c) | 0x24) == 'w')
|
||||||
|
|
||||||
#define INSERT_CODE(at, num, pc) \
|
#define INSERT_CODE(at, num, pc) \
|
||||||
((code ? memmove(code + at + num, code + at, pc - at) : 0), pc += num)
|
((code ? memmove(code + at + num, code + at, pc - at) : 0), pc += num)
|
||||||
#define REL(at, to) (to - at - 2)
|
#define REL(at, to) (to - at - 2)
|
||||||
@ -31,7 +34,7 @@ static const char *_compilecode(const char *re, ByteProg *prog, int sizecode)
|
|||||||
case '\\':
|
case '\\':
|
||||||
re++;
|
re++;
|
||||||
if (!*re) return NULL; // Trailing backslash
|
if (!*re) return NULL; // Trailing backslash
|
||||||
if ((*re | 0x20) == 'd' || (*re | 0x20) == 's' || (*re | 0x20) == 'w') {
|
if (MATCH_NAMED_CLASS_CHAR(*re)) {
|
||||||
term = PC;
|
term = PC;
|
||||||
EMIT(PC++, NamedClass);
|
EMIT(PC++, NamedClass);
|
||||||
EMIT(PC++, *re);
|
EMIT(PC++, *re);
|
||||||
|
Loading…
Reference in New Issue
Block a user