Skip to content

Commit 840373f

Browse files
authored
Merge pull request #4495 from tyomitch/patch-1
[ure] to save space, disable debug dumps by default
2 parents b274a04 + d7dc380 commit 840373f

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

extmod/modure.c

+12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
#include "re1.5/re1.5.h"
2020

21+
#if CIRCUITPY_RE_DEBUG
2122
#define FLAG_DEBUG 0x1000
23+
#endif
2224

2325
typedef struct _mp_obj_re_t {
2426
mp_obj_base_t base;
@@ -401,18 +403,24 @@ STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) {
401403
}
402404
mp_obj_re_t *o = m_new_obj_var(mp_obj_re_t, char, size);
403405
o->base.type = &re_type;
406+
#if CIRCUITPY_RE_DEBUG
404407
int flags = 0;
405408
if (n_args > 1) {
406409
flags = mp_obj_get_int(args[1]);
407410
}
411+
#else
412+
(void)n_args;
413+
#endif
408414
int error = re1_5_compilecode(&o->re, re_str);
409415
if (error != 0) {
410416
error:
411417
mp_raise_ValueError(translate("Error in regex"));
412418
}
419+
#if CIRCUITPY_RE_DEBUG
413420
if (flags & FLAG_DEBUG) {
414421
re1_5_dumpcode(&o->re);
415422
}
423+
#endif
416424
return MP_OBJ_FROM_PTR(o);
417425
}
418426
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_compile_obj, 1, 2, mod_re_compile);
@@ -456,7 +464,9 @@ STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = {
456464
#if MICROPY_PY_URE_SUB
457465
{ MP_ROM_QSTR(MP_QSTR_sub), MP_ROM_PTR(&mod_re_sub_obj) },
458466
#endif
467+
#if CIRCUITPY_RE_DEBUG
459468
{ MP_ROM_QSTR(MP_QSTR_DEBUG), MP_ROM_INT(FLAG_DEBUG) },
469+
#endif
460470
};
461471

462472
STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table);
@@ -471,7 +481,9 @@ const mp_obj_module_t mp_module_ure = {
471481

472482
#define re1_5_fatal(x) assert(!x)
473483
#include "re1.5/compilecode.c"
484+
#if CIRCUITPY_RE_DEBUG
474485
#include "re1.5/dumpcode.c"
486+
#endif
475487
#include "re1.5/recursiveloop.c"
476488
#include "re1.5/charclass.c"
477489

ports/unix/mpconfigport.h

+1
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,4 @@ void mp_unix_mark_exec(void);
325325

326326
#define MICROPY_PY_BUILTINS_HELP (1)
327327
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
328+
#define CIRCUITPY_RE_DEBUG (1)

py/circuitpy_mpconfig.mk

+3
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ CFLAGS += -DCIRCUITPY_RANDOM=$(CIRCUITPY_RANDOM)
242242
CIRCUITPY_RE ?= $(CIRCUITPY_FULL_BUILD)
243243
CFLAGS += -DCIRCUITPY_RE=$(CIRCUITPY_RE)
244244

245+
CIRCUITPY_RE_DEBUG ?= 0
246+
CFLAGS += -DCIRCUITPY_RE_DEBUG=$(CIRCUITPY_RE_DEBUG)
247+
245248
CIRCUITPY_REPL_BLE ?= 0
246249
CFLAGS += -DCIRCUITPY_REPL_BLE=$(CIRCUITPY_REPL_BLE)
247250

0 commit comments

Comments
 (0)