mirror of
https://github.com/python/cpython.git
synced 2025-10-30 05:01:30 +00:00
Issue 2260: Small peephole optimization -- eliminate unnecessary POP_TOP /JUMP_FORWARD 1 pairs.
This commit is contained in:
parent
a2a08fb932
commit
e56131b60e
1 changed files with 10 additions and 0 deletions
|
|
@ -430,6 +430,16 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
|
||||||
cumlc = 0;
|
cumlc = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Replace POP_TOP JUMP_FORWARD 1 POP_TOP
|
||||||
|
with NOP NOP NOP NOP POP_TOP. */
|
||||||
|
case POP_TOP:
|
||||||
|
if (UNCONDITIONAL_JUMP(codestr[i+1]) &&
|
||||||
|
GETJUMPTGT(codestr, i+1) == i+5 &&
|
||||||
|
codestr[i+4] == POP_TOP &&
|
||||||
|
ISBASICBLOCK(blocks,i,4))
|
||||||
|
memset(codestr+i, NOP, 4);
|
||||||
|
break;
|
||||||
|
|
||||||
/* Try to fold tuples of constants (includes a case for lists
|
/* Try to fold tuples of constants (includes a case for lists
|
||||||
which are only used for "in" and "not in" tests).
|
which are only used for "in" and "not in" tests).
|
||||||
Skip over BUILD_SEQN 1 UNPACK_SEQN 1.
|
Skip over BUILD_SEQN 1 UNPACK_SEQN 1.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue