Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4dd4052

Browse files
committed
Fix 2 oversights from r69961.
1 parent 56420b4 commit 4dd4052

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Python/peephole.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
425425
cumlc = lastlc + 1;
426426
j = GETARG(codestr, i);
427427
if (codestr[i+3] != POP_JUMP_IF_FALSE ||
428-
!ISBASICBLOCK(blocks,i,7) ||
428+
!ISBASICBLOCK(blocks,i,6) ||
429429
!PyObject_IsTrue(PyList_GET_ITEM(consts, j)))
430430
continue;
431431
memset(codestr+i, NOP, 6);
@@ -516,8 +516,10 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
516516
"if a or b:"
517517
"a and b or c"
518518
"(a and b) and c"
519-
x:POP_OR_JUMP y y:POP_OR_JUMP z --> x:POP_OR_JUMP z
520-
x:POP_OR_JUMP y y:JUMP_OR_POP z --> x:POP_JUMP_IF_FALSE y+3
519+
x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_FALSE_OR_POP z
520+
--> x:JUMP_IF_FALSE_OR_POP z
521+
x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_TRUE_OR_POP z
522+
--> x:POP_JUMP_IF_FALSE y+3
521523
where y+3 is the instruction following the second test.
522524
*/
523525
case JUMP_IF_FALSE_OR_POP:

0 commit comments

Comments
 (0)