Skip to content

Commit baf29b2

Browse files
authored
Reuse identifier of PREDICT macros as PREDICT_ID (GH-17155)
In function `_PyEval_EvalFrameDefault`, macros PREDICT and PREDICTED use the same identifier creation scheme, which may be shared between them, reducing code repetition, and do ensure that the same identifier is generated.
1 parent d4331c5 commit baf29b2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Python/ceval.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,21 +921,23 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
921921
922922
*/
923923

924+
#define PREDICT_ID(op) PRED_##op
925+
924926
#if defined(DYNAMIC_EXECUTION_PROFILE) || USE_COMPUTED_GOTOS
925-
#define PREDICT(op) if (0) goto PRED_##op
927+
#define PREDICT(op) if (0) goto PREDICT_ID(op)
926928
#else
927929
#define PREDICT(op) \
928-
do{ \
930+
do { \
929931
_Py_CODEUNIT word = *next_instr; \
930932
opcode = _Py_OPCODE(word); \
931-
if (opcode == op){ \
933+
if (opcode == op) { \
932934
oparg = _Py_OPARG(word); \
933935
next_instr++; \
934-
goto PRED_##op; \
936+
goto PREDICT_ID(op); \
935937
} \
936938
} while(0)
937939
#endif
938-
#define PREDICTED(op) PRED_##op:
940+
#define PREDICTED(op) PREDICT_ID(op):
939941

940942

941943
/* Stack manipulation macros */

0 commit comments

Comments
 (0)