diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-04-09 00:17:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 00:17:31 (GMT) |
commit | 58bafe42ab161473ba36c9231c3bf2e64ac8db82 (patch) | |
tree | a482212bcff5e4e6b2f0a50021cab6c08905e0a7 /Parser/pegen.c | |
parent | 54366953633dbe5d9585dbae0c633d4e92df2d04 (diff) | |
download | cpython-58bafe42ab161473ba36c9231c3bf2e64ac8db82.zip cpython-58bafe42ab161473ba36c9231c3bf2e64ac8db82.tar.gz cpython-58bafe42ab161473ba36c9231c3bf2e64ac8db82.tar.bz2 |
Sanitize macros and debug functions in pegen.c (GH-25291)
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r-- | Parser/pegen.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index 729b747..0aa55cf 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -725,6 +725,8 @@ _PyPegen_fill_token(Parser *p) return 0; } + +#if defined(Py_DEBUG) // Instrumentation to count the effectiveness of memoization. // The array counts the number of tokens skipped by memoization, // indexed by type. @@ -761,6 +763,7 @@ _PyPegen_get_memo_statistics() } return ret; } +#endif int // bool _PyPegen_is_memoized(Parser *p, int type, void *pres) @@ -776,6 +779,7 @@ _PyPegen_is_memoized(Parser *p, int type, void *pres) for (Memo *m = t->memo; m != NULL; m = m->next) { if (m->type == type) { +#if defined(PY_DEBUG) if (0 <= type && type < NSTATISTICS) { long count = m->mark - p->mark; // A memoized negative result counts for one. @@ -784,6 +788,7 @@ _PyPegen_is_memoized(Parser *p, int type, void *pres) } memo_statistics[type] += count; } +#endif p->mark = m->mark; *(void **)(pres) = m->node; return 1; @@ -2286,9 +2291,9 @@ _PyPegen_get_invalid_target(expr_ty e, TARGETS_TYPE targets_type) } #define VISIT_CONTAINER(CONTAINER, TYPE) do { \ - Py_ssize_t len = asdl_seq_LEN(CONTAINER->v.TYPE.elts);\ + Py_ssize_t len = asdl_seq_LEN((CONTAINER)->v.TYPE.elts);\ for (Py_ssize_t i = 0; i < len; i++) {\ - expr_ty other = asdl_seq_GET(CONTAINER->v.TYPE.elts, i);\ + expr_ty other = asdl_seq_GET((CONTAINER)->v.TYPE.elts, i);\ expr_ty child = _PyPegen_get_invalid_target(other, targets_type);\ if (child != NULL) {\ return child;\ |